I have one one http server running on 1337.

and another http server running on 4040.

Requirment: I am trying to tunnel them both through https on port 443 using apache2

I have already succeeded (I think) in tunneling the server on port 1337, and i can see the content with no issue.

the following is my vhost configuration

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    ServerAdmin webmaster@localhost
    ServerName 127.0.0.1
    DocumentRoot /var/www/html



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


    SSLEngine on


    SSLCertificateFile  /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile /etc/apache2/ssl/apache.key
    ProxyPreserveHost On

    ProxyPass /parse http://localhost:1337/

    ProxyPassReverse / http://localhost:1337/


    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0

    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

</VirtualHost>

now I want to add 4040 as well, so it would be secured, how ever when I add another

proxyPass /dashboard http://127.0.0.1:4040/

PROBLEM It does not properly work. and it only renders the page title and the icon.

I might be doing this whole reverse proxy thing incorrectly, kindly any explanation is appreciated!

(OS: Ubuntu 14.04)

  • we have lots of Q&A already about apache reverse proxy - you shpud try searching for it. – Iain Aug 3 '16 at 17:14
  • i did, but still didnt get it, so im wondering if anybody could help. – user3676224 Aug 3 '16 at 17:17
up vote 0 down vote accepted

When using proxypass you need to match slashes back and forth, that is if you don't end in slash with the source URI you want to forward you shouldn't end in / the target and so on.

The only exception is that http://localhost:1337 is equivalent to http://localhost:1337/ so you should never do: ProxyPass /parse http://localhost:1337 (or otherwise expect the unpexpected)

So the correct way to do your ProxyPass is:

ProxyPass /parse/ http://localhost:1337/
ProxyPass /dashboard/ http://127.0.0.1:4040/

This is mainly why your proxypass directives are working erratically now. Take into account there are other considerations you should take, mainly depending on the "backend" responses, but to have basic forwarding correctly in place, always remember to match the slashes.

SideNote: Should you need /parse to work in this case you could just redirect to the correct path: RedirectMatch ^/parse /parse/ or whatever URI you need.

  • Thank you this did solve the main issue. I also realized that the problem with connecting was that, google chrome was prevents scripts from being run(with tiny shield and a small red button on it). Once i allowed it to load the scripts things where following. so I check the developers console, and its has many errors, main due to this "Mixed Content: The page at" and the reason is /dashboard loads with https but /parse only loads with http. maybe its due to the proxypassReverse ? – user3676224 Aug 4 '16 at 18:18
  • probably, can't really tell without looking at it closely. – ezra-s Aug 9 '16 at 13:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.