I have a weird issue happening in my Nginx server. I am using Nginx as a reverse proxy for multiple services running on my servers internally.
This is kind of what I was trying to accomplish:
app1.mydomain.com --- --- server 1: 10.0.0.2 \ 10.0.0.1 / |--- nginx reverse proxy server --- | / \ app2.mydomain.com --- --- server 2: 10.0.0.3 So I added the first one for app1, added the DNS settings in my domain provider, and everything worked perfectly. I was pretty excited so I went for the second one and then everything broke. I ran nginx -t and everything tested fine. The Nginx server was still running without error but I lost the ability to view app1.mydomain.com
The configs are basically the same except for the server_name and the proxy_pass
file: /etc/nginx/sites-available/app1.mydomain.com
server { server_name app1.mydomain.com; location / { client_max_body_size 512M; proxy_pass http://10.0.0.2; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } file: /etc/nginx/sites-available/app2.mydomain.com
server { server_name app2.mydomain.com; location / { client_max_body_size 512M; proxy_pass http://10.0.0.3; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } The way I did this was adding each config in it's own file in sites-available and then doing sudo ln -s /etc/nginx/sites-available/app1.mydomain.com /etc/nginx/sites-enabled/
This worked perfectly for app1, but after doing that for app2 I lost access to app1 and app2 wouldn't appear.
In my router, I forwarded port 80 and 443 to the reverse proxy server 10.0.0.1 and those are the only rules on my router. On my domain name provider I have the correct A records pointed at the correct IP. I was able to verify everything works with app 1, but after doing a symlink for app 2 to go into sites-enabled and restart nginx I lose access to everything.
Any ideas as to what is going on? Thanks!
nginx -Tshow?nginx -tjust showsnginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successfulnginx -T, note the capitalT. That will display the full configuration.