Reverse Proxy setup for Tomcat App on Subdomain

18 views Asked by At

I'm using a linux server managed by cpanel. I have an auto generated httpd.conf file in path /etc/apache2/conf/httpd.conf that includes a few lines:

#Administrator locations for safely altering httpd.conf
Include "/etc/apache2/conf.d/includes/pre_main_global.conf"

# Major Version Specific
Include "/etc/apache2/conf.d/includes/pre_main_2.conf"

and

# Administrator locations for safely altering virtualhost configuration
Include "/etc/apache2/conf.d/includes/post_virtualhost_global.conf"

# Major Version Specific
Include "/etc/apache2/conf.d/includes/post_virtualhost_2.conf"

I added my virtual host config to post_virtualhost_2.conf. See below. The subdmain returns a 404 error; however, the cert loads correctly on https://services.example.com/ and the "apachectl configtest" is successful. I can also successfully curl the http://localhost:8080/ on the server and get a response from the tomcat app. I have restarted the apache2 service multiple times.

post_virtualhost_2.conf

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

    # Redirect HTTP to HTTPS
    Redirect permanent / https://services.example.com/
</VirtualHost>

<VirtualHost *:443>
    ServerName services.example.com
    ServerAlias www.services.example.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/services.example.com.crt
    SSLCertificateKeyFile /etc/apache2/ssl/services.example.com.key

    # Other SSL settings go here


    ProxyRequests off

    <Proxy *>
    Order deny,allow
        Allow from all
    </Proxy>
    # Disable OCSP stapling
    SSLUseStapling Off
    <Location />
        ProxyPass http://localhost:8080/
        ProxyPassReverse http://localhost:8080/

        ProxyPreserveHost On
        RequestHeader set X-Forwarded-Proto "https"
    </Location>
</VirtualHost>

Error from the subdmain

*Not Found The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.*

Im expecting a response from the tomcat app running successfully on the port 8080

0

There are 0 answers