How to deal with absolute directories in Nginx reverse proxy?
PHP中文网
PHP中文网 2017-06-16 09:19:40
0
1
961

Scene requirements

Now we need to design an external gateway server to act as an agent for many other services within the company.
The method currently used is nginx reverse proxy.
The code in Nginx.conf is as follows

location ^~ /services/ {
    ...
    proxy_pass 真实uri
    ...
}

Problems encountered

Problems may occur when the html code of a certain service contains resource access or jump to an absolute directory.

For example, you want to proxy the abc website 10.10.10.10/
The html of this website contains access to the /static/a.jpg resource.

When a user accesses my gateway server, the methods called are
Get www.xxx.com/services/abc
Get www.xxx.com/static/a.jpg. At this time, get fail.

The existing temporary solution is to add a proxy for the absolute directory of the abc website in nginx.conf, as follows

location /static/ {
    proxy_pass http://10.10.10.10/static/;
}

But if there are too many services, there will be conflicts.

How to solve the problem?

Thank you for browsing.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
Ty80

Why not configure several subdomains abc.xxx.com

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template