My setup: a raspberry pi which is part of 2 LAN's (192.168.1.* and 192.168.2.*), running nginx. I would like to setup nginx as a reverse proxy, so I can access the router of the first LAN from the second LAN.

So from a computer in the second LAN (let's say I want to go to the address of the pi in the second LAN (let's say, and I want to get forwarded to the web interface of the router in the first LAN (

With the setup I did, this works partially: it forwards to the correct location but there are problems loading the site, as for every .js and .css file I get a 403 error 'forbidden'.

Accessing the router website directly from the pi works without issues, so the problem is linked to the config of the reverse proxy.

Here's what I have setup and the error messages (what I don't specify means it's at default value/setting)


location / {
  proxy_bind    ;
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
} is the address of the pi in the first LAN. is the address of the router (part of the first LAN) I want to access.

Example error I see in the developer console of web browser (this goes for all .js and .css files):

 HTTP403: FORBIDDEN - The server understood the request, but is refusing to fulfil it.

Corresponding line in the access.log of nginx:

 "GET /css/main.css HTTP/1.1" 403 100 "" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKi
t/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"

I'm not sure, but in the line above it shows as the referrer. Since the router is in the 192.168.1.* LAN I'm thinking this might be causing the persmission issue. Playing with the "proxy_set_header Referer" yields exactly the same results however, so I might be wrong there?

Corresponding html line in the source file (seen when using curl directly from the pi):

 <link rel="stylesheet" href="../css/main.css">

I have already tried many different settings (I played with the header Host/Referer/X-Forwarded-For) but the result is always the same. Since it's the built-in website of the router, I cannot change permissions on these files (I don't think it's necessary as it works fine without using the proxy).

What am I missing?

Thank you in advance, Wim

Your Answer

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

Browse other questions tagged or ask your own question.