How can I use a ProxyPass
and DirectoryIndex
at the same time?
I have the following rule:
# Index
DirectoryIndex index.html
# Service Endpoint
ProxyPass /endpointA http://127.0.0.1:wxyz/
ProxyPassReverse /endpointA http://127.0.0.1:wxyz/
# Root Endpoint
ProxyPass / http://127.0.0.1:8080/static/
ProxyPassReverse / http://127.0.0.1:8080/static/
The expected behavior is that when a user hits the machine at /
, they should be served 127.0.0.1:8080/static/index.html
I however, am getting a 404 from the /static/
endpoint as it appears there is no default page trying to be loaded; this all works correctly if I hit
/index.html
Which routes me to 127.0.0.1:8080/static/index.html
How can I have a ProxyPass and a DirectoryIndex working at the same time, or some other combination of configuration, so that when a user simply hits
/
, they are routed to127.0.0.1:8080/static/index.html
and not just127.0.0.1:8080/static
?
The problem is that the DirectoryIndex won't be used because the server's already matched the ProxyPass /, and so it's already been passed to the other server.
You should set the DirectoryIndex on your backend server. ie The one on port 8080.
I have tested several ways and the only one who yielded the same result you seem to want for me as of now has seem to be using mod_rewrite as in:
RewriteEngine on
RewriteRule ^/$ http://127.0.0.1:8080/static/index.html [P,L]
then you can add the rest:
RewriteRule ^/(.+) http://127.0.0.1:8080/static/$1 [P,L]
This may be a rough way to do it.
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.