There are many tutorials out there explaining how to set up nginx 1.4.6 as a load balancer but I did not get beyond receiving a 502 Bad Gateway or 403 Forbidden configuring it on an Ubuntu 14.04 server with ssh only (no apache or lighttpd, no application running). After installing nginx and running the service, I get the default nginx page when I enter the domain (A record pointing to the IP of the machine).

The nginx.conf looks as follows. All I added is the upstream and server config. This now results in displaying the default nginx page instead of showing the content on the servers defined for load balancing.

user www-data;
worker_process 4;
pid /run/nginx.pid;

events {
        worker_connections 768;

http {
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        gzip on;
        gzip_disable "msie6";

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        upstream appdomain.org {
                server s1.appdomain.org;
                server s2.appdomain.org;

        server {
                listen 80;
                location / {
                        proxy_pass http://appdomain.org;

1 Answer 1


you are getting the default nginx page because it is reading from a file in


take your upstread and server block and move it in the /etc/nginx/sites-enabled/default file or whatever is there and restart nginx it might start working

  • Thanks. I am getting an 403 Forbidden. You don't have permission to access / on this server. now. I don't want to access a local directory.
    – Steven
    Oct 31, 2014 at 12:20
  • Okay, it was a cross-site script that caused this error. The script works as in my question. I did not even have to move it to default as this file is included anyways in the nginx.conf.
    – Steven
    Oct 31, 2014 at 12:40
  • are your backend servers listening to port 80 for incoming requests?
    – Mike
    Oct 31, 2014 at 13:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.