Apache Rewriteengine affecting Tomcat - Ubuntu 16 server

Asked

Viewed 43 times

0

I have the following problem.

I have set up the htaccess file so that all requests are redirected to using ssl (https). So far everything worked correctly, but recently I installed Tomcat on the server and had to "ignore" the redirect in case of access by port 8080 (standard port of Tomcat), I modified the htaccess file as follows:

RewriteEngine On

# Redirect all HTTP traffic to HTTPS.
RewriteCond %{HTTPS} !=on
RewriteCond "%{SERVER_PORT}" "!^8080$"
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [L,NC,R]

# Send / to /roundcube.
RewriteRule ^/?$ /roundcube [L]

However, when trying to access the domain through the browser on port 8080 "my.hostname.com.br:8080" it rewrites the URL to "https://my.hostname.com.br:8080" I would like that in this specific case there was no change or when accessed "my.hostname.com.br:8080" just access "http://my.hostname.com.br:8080" normally.

How should I proceed?

  • Solution I found was to create a new domain

1 answer

0


After creating a new subdomain I was able to make the specific rewrite configuration for Subdomain.

in the file "/etc/apache2/sites-enabled/000-default.conf" includes the following treatment.

<VirtualHost *:80>
        ServerName tomcat.mydomain.com

        ServerAdmin [email protected]
        LogLevel warn
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =tomcat.mydomain.com
RewriteRule ^ http://%{SERVER_NAME}:8080%{REQUEST_URI}
</VirtualHost>

For me it was decided, because using another subdomain exclusive to Tomcat was even better for me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.