0

I have the below apache virtualhost configuration. ProxyPassReverse does not appear to be converting the URLs properly.

URL http://www.example.com/9999pcap/ shows a directory listing on a remote device and the directory listing looks fine but if you click on a file captype1.pcap1.gz to download it you get

The requested URL /captype1.pcap1.gz was not found on this server

and the URL bar shows /captype1.pcap1.gz. If you manually change the URL to /9999pcap/captype1.pcap1.gz it properly downloads the file.

[Sat Dec 06 19:19:33.265254 2014] [core:info] [pid 22470:tid 139711796442880] [client 127.0.0.1:56469] AH00128: File does not exist: /var/www/html/captype1.pcap1.gz, referer: http://www.example.com/9999pcap/

URL /9999/ shows the login page of a remote device but it looks wrong because it's not properly downloading style sheets and other files and attempting to login fails with

The requested URL /cgi-bin/luci/ was not found on this server.

Can anyone tell me what I'm doing wrong here? Thanks!

<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        DirectoryIndex index.html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        LogLevel debug

        ProxyRequests Off
        ProxyPreserveHost Off

        <Proxy *>
                Order Allow,Deny
                Allow from all
        </Proxy>

        <Location /9999/>
                ProxyPass http://localhost:22002/cgi-bin/luci/
                ProxyPassReverse http://localhost:22002/cgi-bin/luci/
        </Location>
        <Location /9999pcap/>
                ProxyPass http://localhost:22003/
                ProxyPassReverse http://localhost:22003/
        </Location>
</VirtualHost>
masegaloeh
  • 18,236
  • 10
  • 57
  • 106
Aedan Renner
  • 1
  • 1
  • 3

1 Answers1

0

apache proxypassreverse ServerName not working

I gave up on this method as it doesn't work as it should. Simply manually substituting URL pieces works just fine as shown in this post.

<Location /9999pcap/>
        ProxyPass http://localhost:22003/
        ProxyPassReverse http://localhost:22003/
        Substitute s>href='/>href='/9999pcap/>
        SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE
        RequestHeader unset Accept-Encoding
</Location>
Aedan Renner
  • 1
  • 1
  • 3
  • Oh that hurts to look at. – Carl F. Dec 16 '14 at 13:42
  • FYI, the reason this doesn't work is normal http proxying doesn't modify the HTML (Your Substitute directive does that). If you want mod_proxy to do the work in and 'HTML aware way' you can use mod_proxy_html – Unbeliever Sep 07 '16 at 18:49