Welcome! Log In Create A New Profile

Advanced

nginx proxy to subdirectory

Posted by BlackDragon381 
nginx proxy to subdirectory
March 24, 2016 05:24AM
Hello, I have a problem with nginx proxy.

I have site on server with IIS at "http://192.168.1.1:80/"
and want to see it at subdirectory like "http://localhost/site1/"

I configure config file as
location /site1/ {
rewrite ^/site1(/.*)$ $1 break;
proxy_pass http://192.168.1.10:80/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header X-Forwarded-Proto https;
proxy_redirect off;
}
but have a blank page, becouse all css file have get query
to "http://localhost/somecss.css"
insted "http://localhost/site1/somecss.css"

How to fix this?
Re: nginx proxy to subdirectory
March 24, 2016 06:02AM
Remove the trailing '/' for proxy_pass

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: nginx proxy to subdirectory
March 24, 2016 06:55AM
itpp2012 Wrote:
-------------------------------------------------------
> Remove the trailing '/' for proxy_pass

It doesn't work
Re: nginx proxy to subdirectory
March 24, 2016 07:11AM
Disable the rewrite.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: nginx proxy to subdirectory
March 24, 2016 07:39AM
itpp2012 Wrote:
-------------------------------------------------------
> Disable the rewrite.

Server Error in '/' Application.

The resource cannot be found.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Requested URL: /site1/
Re: nginx proxy to subdirectory
March 24, 2016 09:50AM
Have a good look at the logfiles, what is being requested and what is being passed on to the backend, often when using a debug build and the debug log you can see the re-write happening and figure out what the config is doing when it is parsed.

location /site1 {
proxy_pass http://192.168.1.10:80;
}

or,

location /site1/ {
rewrite /site1/([^/]+) /$1 break;
proxy_pass http://192.168.1.10:80/;
}

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 264
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready