I have the following setup on the same network:
192.168.1.23
192.168.1.15
9000
9001
9002
The apps are running on Docker containers on the server and are accessible on the windows computer using the following URLs http://192.168.1.15:9000/
, http://192.168.1.15:9001/
, http://192.168.1.15:9002/
.
Now, I wish to configure an NGINX reverse proxy in order to access the various services by typing http://gitea.test.dev/
, http://homarr.test.dev/
, http://nextcloud.test.dev/
.
In order to do that locally, I modified the host files on both platforms:
# windows
192.168.1.15 test.dev
192.168.1.15 gitea.test.dev
192.168.1.15 homarr.test.dev
192.168.1.15 nextcloud.test.dev
# linux
127.0.0.1 localhost
127.0.0.1 gitea.localhost
127.0.0.1 homarr.localhost
127.0.0.1 nextcloud.localhost
On the archlinux server, I can access the individual services at that point using the above method. However, I am unable to access those services from the windows computer using http://<service name>.test.dev/
-like URLs, although that is expected behavior for now.
I then configured and started an NGINX service using the following configuration:
# /etc/nginx/nginx.conf
user http;
worker_processes auto;
worker_cpu_affinity auto;
events {
multi_accept on;
worker_connections 1024;
}
http {
charset utf-8;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
log_not_found off;
types_hash_max_size 4096;
client_max_body_size 16M;
# MIME
include mime.types;
default_type application/octet-stream;
# logging
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log debug;
# load configs
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
And the directory /etc/nginx/sites-enabled/
contains links to the individual services' configurations.
# /etc/nginx/sites-enabled/homarr.localhost.conf
server {
listen 80;
server_name homarr.localhost;
location / {
proxy_pass http://localhost:9000;
}
}
# /etc/nginx/sites-enabled/nextcloud.localhost.conf
server {
listen 80;
server_name nextcloud.localhost;
location / {
proxy_pass http://localhost:9001;
}
}
# /etc/nginx/sites-enabled/gitea.localhost.conf
server {
listen 80;
server_name gitea.localhost;
location / {
proxy_pass http://localhost:9002;
}
}
Those are, I believe, very bare-bone proxy_pass
configurations. But I would expect them to work as intended. Now, my problem is that only one of these services is available from the windows computer using http://test.dev/
or http://<service>.test.dev/
>. It seems to me like the default_server
is the only one that is made available because the available service always follows the alphabetical ordering of the service names, and surely that is the order in which they are loaded by the include
statement of the configuration.
Do you have any idea of why my individual services can't all be serviced at the same time ? And is there any way to have a working configuration for the intended purpose of having all three services available on different subdomains on the local network ?
Your server_name
values are wrong in your site config files. You have
but they should be
If you want both names to work, you can have both in the config file like this
server_name homarr.localhost homarr.test.dev;
but for it to work, the server_name
has to match what's in the Host
header in the incoming request.