Hi! I'm new to whole nginx thing and trying to figure out how to get this thing work. Here's the what: - 1 DNS - 2 nginx servers - 1 app server and why: Nginx is supposed to be used to load balance traffic coming from internet and redirect it to app server. At this moment there is only 1 app server because I wanted to simplify things and get things to work first. Later there are supposed to be 2 app servers. Anyway, app server name is advertised(not sure if correct word) to DNS. DNS record points to nginx load balancers. Load balancer points to app server and to a specific port. - I've made sure that DNS setting is correct. Using nslookup to query DNS name of app server I get 2 different IPs (=nginx server IPs). - Nginx config is very simple, here's the code (same in both nginx servers): --- BEGIN --- upstream SERVER_NAME { server IPORT; } server { listen 80; location / { proxy_pass http:// SERVER_NAME; } } --- END --- ^ that server IP is the app servers IP - I've tried telnetting from nginx servers to app server port and established successfully connection. - I've checked that the app is running in the app server. So all in all, everything seems to be working OK, except it is not. When I try to use browser (Chrome, Firefox, Edge) and navigate to servers page I get "site not found" error. I really can't figure out where I went wrong. Also when checked nginx log files I get no indication of successful connection to server. Any and all help would be GREATLY appreciated. Thanks in advance!
You are missing the 'server_name' directive. Try with the following code: upstream APP_NAME { server IP:PORT; } server { listen 80; server_name yourDomainName.com; access_log /var/log/nginx/APP_NAME.access.log; error_log /var/log/nginx/APP_NAME.error.log; proxy_buffers 16 64k; proxy_buffer_size 128k; location / { proxy_pass http://APP_NAME; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } Code (markup):