1

I have the following setup:

  • NGINX setup as a reverse proxy on Raspberry Pi (its sole purpose)
  • -reverse proxy working great for other IPs on the LAN as well as several ports to services on a single Windows desktop

I have an issue with just 1 LAN device I cannot get to reverse proxy. It is a remote IP Power Switch (3GStore)

The DNS host entry within the IP Power Switch is "Outlet" so therefore within the LAN navigating to http://Outlet brings up the interface and if you instead type in the IP and hit enter the same page loads and the address bar populates with the local IP address 192.168.0.xxx/index.asp

thinking the port the IP Power Switch might have been the issue since it is also on port 80, I changed it to 9080 instead

this is the block I have within the config file I created within NGINX (that seems to work for the rest of the my reverse proxied devices/services but IS NOT working for this IP Power Switch)

server {
    listen 80;
    server_name mydomaincom;
    location /powerswitch/ {
        proxy_pass http://192.168.0.xxx:9080/;
        include /etc/nginx/proxy_params;
    }
}

Navigating to mydomaincom/powerswitch results in an NGINX 404 Not Found Error

Any suggestions would be greatly appreciated!

2
  • When you inside of your local network, does this link http://192.168.0.xxx:9080/ work ? – Alex Feb 17 '17 at 6:51
  • nginx will NOT rewrite the URL when it passes it to the destination device unless you tell it. So unless your device has something on its webserver that responds to "192.168.0.xxx:9080/powerswitch" you will not get anything. @unNamed's answer is what you need to do. – LawrenceC Mar 3 '17 at 17:34
1

Your config has two faults:

  1. The site of your IP Power Switch is redirecting and therefore not available externally.

  2. You are forwarding the requests to the wrong position for your device.

Try this config:

server {
  listen 80;
  server_name my.domain.com;
  location /powerswitch/ {
    rewrite /powerswitch(/.*) $1 break;
    proxy_redirect / /powerswitch/;
    proxy_pass http://192.168.0.xxx;
  }
}

I've edited the rewrite, the proxy_pass and added proxy_redirect.

0

yes, navigating to the local IP address and port works...redirects to http://192.168.0.xxx/index.asp

I've since switch the port back from 9080 back to 80

further trial and error and I got it to work (?halfway?) with this entry:

server {
     listen 80;
     server_name my.domain.com;
     location /powerswitch/ {
         rewrite /powerswitch/(.*) /$1 break;
         proxy_pass http://192.168.0.xxx/powerswitch/;
         }
}

So now my.domain.com/powerswitch loads the IP Power Switch's interface locally on the LAN...BUT, externally pulling up the my.domain.com/powerswitch states the page isn't working (shows local IP in address bar: 192.168.0.xxx/index.asp; tested on phone cellular/wifi off)

1
  • Until it isn't resolved, edit you question and add details there. When you inserting nginx's config, select with mouse lines that should keep original formatting and press button {}, so it would be readable – Alex Feb 17 '17 at 7:24

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.