0

I've just installed nginx on my Netgear R7000 with DD-WRT firmware, but I'm unable to set it up to use it as a reverse proxy for my different webservers (running on a public ip).

This is the setup:

user  nobody;
worker_processes  1;

#error_log  /opt/var/log/nginx/error.log;
#error_log  /opt/var/log/nginx/error.log  notice;
#error_log  /opt/var/log/nginx/error.log  info;

pid        /opt/var/run/nginx.pid;


events {
    worker_connections  64;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 64;
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /opt/var/log/nginx/access.log main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  /opt/var/log/nginx/host.access.log;

        location / {
            root   /opt/share/nginx/html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    server {
        listen       80;
        #listen       somename:8080;
        server_name  xxx.xxxx.it;

        location / {
            proxy_pass http://192.168.x.xxx:5000;
        }
    }


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

The error is

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

What is wrong?

Thank you in advance

Jokerigno
  • 1
  • 3

1 Answers1

0

Port 80 is the default HTTP port and it is most likely being used by the DD-WRT admin interface. You will need to bind your reverse proxy to a different port or change the port DD-WRT's HTTP server listens on.

sangnoir
  • 1
  • 1
  • I have done as you kindly suggested me. Now the router is reachable on another port. Nginx server is working (if I write the IP address of the router I receive the nginx welcome page) but nothing happens. I can only connect to my Nas, whatever the subdomain is. – Jokerigno Apr 14 '17 at 16:18
  • @Jokerigno, your current nginx configuration is se to serve the nginx welcome page - if you do not want that, comment out the following location / { root /opt/share/nginx/html; index index.html index.htm; } – sangnoir Apr 15 '17 at 19:13
  • I've changed the nginx config and the router firmware. Nothing changed. If i try to connect to my public ip from outside I can't see the nginx welcome page. – Jokerigno Apr 21 '17 at 12:38
  • @Jokerigno hi have you solved your problem? I have your exact same issue. I have my nginx listening on port 80 and from the local network i can see the welcome page, but if i try to use my public IP Address it does not show it. I have my main rounter in DMZ on the DDWRT router so should be fine. – Norcino Dec 10 '17 at 11:23
  • After many fails I moved to Asus Merlin firmware (a lot easier). For reverse proxy I'm using caddy server running with docker on my Nas (on 24/7). – Jokerigno Dec 11 '17 at 11:56