0

nginx website behind a router connects ok with myserver.local but asks for username and password when accessed via my myserver.mydomain.com

All I wanted is to expose one of my Node.js test sites to some outside users and it asks for username and password. How can I do this?

My configuration consists of an apt-get(ed) nginx and my website .conf file in /etc/nginx/conf.d/website.conf

server {
        listen          80;
        server_name     myserver.local;

        access_log      /var/log/nginx/myserver.local.access.log combined;
        location / {
                proxy_pass      http://127.0.0.1:8080;
                proxy_set_header        Host    $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

migrated from serverfault.com Mar 14 '15 at 17:25

This question came from our site for system and network administrators.

  • What does "behind a router" mean? – Michael Hampton Mar 14 '15 at 17:11
  • Lan ip is 192.168.0.10 and the router 192.168.0.1 and I forward the 80 port on 192.168.0.10 to port 80 on 192.168.0.1 manually form the router. – unom Mar 14 '15 at 17:14
  • This doesn't sound like a professional setup. Is this some kind of home router? What router? Have you considered the possibility that the router is doing this instead of forwarding the traffic? – Michael Hampton Mar 14 '15 at 17:21
  • It's a Linksys, I do this routinely for VNC or SSH, my external ip never changes so I can ssh directly to a machine on my lan through the router. – unom Mar 14 '15 at 17:25
  • @MichaelHampton any thoughts on this, the 401 Unauthorized is certainly Nginx having some kind of security all around. Maybe it's figuring out URL is myserver.mydomain.com instead of myserver.local – unom Mar 15 '15 at 11:22
0

Managed to fix this one. Had to add the myserver.mydomain.com next to the local one and default.

server {
        listen          80 default;
        server_name     myserver.local myserver.mydomain.com;

        access_log      /var/log/nginx/myserver.local.access.log combined;
        location / {
                proxy_pass      http://127.0.0.1:8080;
                proxy_set_header        Host    $host;
                proxy_set_header        X-Real-IP       $remote_addr;
                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}

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.