TransWikia.com

Apache ProxyPass to Tomcat - how to remove context path from URL?

Server Fault Asked by Justas on January 22, 2021

I have Apache conf:

<IfModule mod_ssl.c>
<VirtualHost *:443>

    ServerName project.example.com
    ServerAlias ci
    ProxyRequests Off

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPreserveHost on
    ProxyPass / http://localhost:1111/project

    SSLCertificateFile /etc/letsencrypt/live/sub.example.com/cert.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/sub.example.com/privkey.pem
    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateChainFile /etc/letsencrypt/live/sub.example.com/chain.pem

</VirtualHost>
</IfModule>

When I enter project.example.com, I get https://project.example.com/project/users/sign_in in a browser. How to remove context path from URL?
I want to remove project from URL and get https://project.example.com/users/sign_in ?

2 Answers

So first would be removing the context root from the application. Unless you define the context as / (blank) you cannot access the application without the context root.

This Solution should give you an idea of how to change the context root. Once you are done with the steps you should be able to access your application at http://localhost:1111/.

Then coming to the httpd configuration remove the project name :

ProxyPass / http://localhost:1111/

Answered by Dextro67 on January 22, 2021

I think you're missing the trailing slash:

ProxyPass / http://localhost:1111/project/

It's also a good idea to define a corresponding ProxyPassReverse:

ProxyPassReverse / http://localhost:1111/project/

Answered by Lukas on January 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP