Riccardo79
Riccardo79

Reputation: 1046

Tomcat port 8080 to 80

I installed Apache2 and Tomcat7 on Ubuntu14

http://mysite.it/                    -> Apache OK
http://mysite.it/phpmyadmin          -> Apache OK, showing phpmyadmin
http://mysite.it:8080/myApp/         -> Tomcat OK, showing my Spring App

The 8080 port is closed in the Client intranet, and he would like to use http://mysite.it/myApp/. I need to setup the proxy/reverse proxy in Apache2

Here there is what I did:

aptitude    update
aptitude -y upgrade
aptitude install -y build-essential
aptitude install -y libapache2-mod-proxy-html libxml2-dev    
a2enmod proxy
a2enmod proxy_http
a2enmod proxy_ajp
a2enmod rewrite
a2enmod deflate
a2enmod headers
a2enmod proxy_balancer
a2enmod proxy_connect
a2enmod proxy_html
a2enmod xml2enc

Now I should modify /etc/apache2/sites-enabled/000-default.conf

The current (default) version is

<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

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

</VirtualHost>

I tried to add also this snippet, but no luck

<VirtualHost *:*>
    ProxyPreserveHost On

    ProxyPass /myApp/ http://mysite.it:8080/
    ProxyPassReverse /myApp/ http://mysite.it:8080/

    ServerName mysite.it
</VirtualHost>

Can anyone help me? Riccardo

***** SOLUTION ****** Just one virtualHost:

<VirtualHost *:*>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

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

    ProxyPreserveHost On

    ProxyPass /myApp/ http://mysite.it:8080/myApp/
    ProxyPassReverse /myApp/ http://mysite.it:8080/myApp/

    ServerName mysite.it

</VirtualHost>

Upvotes: 1

Views: 1007

Answers (1)

David Levesque
David Levesque

Reputation: 22441

You need to include the context name (myApp) at the end the ProxyPass target:

ProxyPass /myApp/ http://mysite.it:8080/myApp/
ProxyPassReverse /myApp/ http://mysite.it:8080/myApp/

instead of

ProxyPass /myApp/ http://mysite.it:8080/
ProxyPassReverse /myApp/ http://mysite.it:8080/

Upvotes: 1

Related Questions