简体   繁体   中英

Apache reverse proxying distorts assets paths

I'm trying to configure a reverse proxy from Apache web server (A) to another Apache web server on different machine (B).

I could manage to access web page located on server B as if it were on server A, but all assets' paths (images, CSSs, JSs etc) were distorted.

I used below configuration on server A:

ProxyPass "/app1/" "http://some.host.address:8080/app1/"
ProxyPassReverse "/app1/" "some.host.address:8080/app1/"
ProxyHTMLURLMap "http://some.host.address:8080" "/app1"

<Location /app1/>
        ProxyPassReverse /app1/
        ProxyHTMLEnable On
        ProxyHTMLURLMap / /app1/
</Location>

What you mean is your backend application is generating links with "some.host.address" instead of the public url you are requesting, because your application generates not relative links but also includes hostname.

Use:

ProxyPreserveHost on

and try again. This will send the same hostname the client has requested to the backend, and then your backend application will use the name you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM