remove 8080 port from tomcat url - apache

I am using httpd and tomcat for my web application,
so i want to remove 8080 port which is coming in my url.
i tried following things
Made <Connector port="80" in server.xml but its not working.
Used Proxypass in httpd.conf
<VirtualHost *:80>
ServerName myapp.com
ServerAlias www.myapp.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /MyAppPath http://localhost:8080
ProxyPassReverse http://localhost:8080
but both of the things are not working.
whenever i am hitting www.mysite.com its showing apache 2.2 page.
To reach out to mysite every time i need to put www.mysite.com:8080/
please guide.
Thanks in Advance

Resolved by pointing tomcat to 80 and stoped the httpd service.
Worked for me.

Related

configure proxy_http for apache2 with tomcat7 and webapp under debian wheezy

I have a vServer with debian 7.8 (wheezy), apache2 webserver and tomcat7.
I deployed a webapp with the apache www.mydomain.com/manager app into /var/lib/tomcat7/webapps/app/ which runs perfectly under www.mydomain.com:8080. It gets linked to my webapp´s welcome page www.mydomain.com:8080/app/#welcome.
My apache2 www.mydomain.com/host-manager lists only “localhost” under host name.
Now I want to connect my apache2 webserver to tomcat7, so that www.mydomain.com starts my webapp (like www.mydomain.com/#welcome).
Things, i have done so far:
enabled proxy_http, which can be found under /etc/apache2/mods-enabled/proxy_http.load
my /etc/apache2/sites-enabled/000-default file looks like
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAlias mydomain.com
ProxyRequest Off
ProxyPreserveHost On
<Proxy*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/
ProxyPassReserve / http://localhost:8080/
DocumentRoot /var/lib/tomcat7/webapps/app/
</VirtualHost>
changed /etc/hosts 127.0.0.1 localhost to 127.0.0.1 www.mydomain.com
my /etc/tomcat7/server.xml looks like
<Server port=”8005” shutdown=”SHUTDOWN”>
...
<Connector port=”8080” protocol=”HTTP/1.1”
...
redirectPort=”8443”
proxyPort=”80”
proxyName=”www.mydomain.com” />
What am i missing?
From your configuration i noted:
whitespace at <_Proxy *> and </Proxy_>
DocumentRoot in combination with proxy configuration, doesn't make sense
if you plan to redirect to localhost:8080/app/ you have to configure this (see below)
I have no tomcat7, but i configured nginx: apache (80) --> proxy --> nginx (8080)
With the following configuration a subdirectoy app from nginx is displayed at port 80 via apache. I hope this will help to answer your question (just works fine with Debian 8):
/etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ProxyVia On
ProxyRequests Off
ProxyPreserveHost on
ProxyPass / http://127.0.0.1:8080/app/ retry=0
ProxyPassReverse / http://127.0.0.1:8080/app/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
enable proxy and restart apache:
a2enmod proxy
a2enmod proxy_http
service apache2 restart
all possible error messages are logged into /var/log/apache2/error.log, you should also take a look at your tomcat logfiles.
If you put the configuration in an other file than 000-default.conf you have to enable the site with a2ensite <sitename> so that apache knows that it exists.

Session Expired on tomcat8 behind apache2 ProxyPass

For a web application named whys written with VAADIN 7.3.8, i deployed a tomcat8 server behind an apache one (and redirected app.whys.fr to whys.fr:8080/Whys wich is my app location).
When i go on http://whys.fr:8080/Whys, everything looks good, but when i go on http://app.whys.fr, i get a session expired message immediatly, and no logs to tell me why (nothing in catalina.out).
You can test it by your own to see the difference ;).
Here is my proxy configuration :
<VirtualHost *:80>
ServerName app.whys.fr
ProxyRequests On
ProxyPass / http://localhost:8080/Whys/
ProxyPassReverse / http://localhost:8080/Whys/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
<VirtualHost *:80>
ServerName whys.fr
</VirtualHost>
and my tomcat Connector in server.xml:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
apache2 has mod_proxy,mod_proxy_http and mod_proxy_connect enabled, timeout for session in web.xml is 30 mins.
EDIT: forgot to mention: my application is using #Push (vaadin feature)
The problem was with vaadin's Push.
With push activated, you need to redirect the cookies throught proxy too, in order to keep your session alive, else, it is instantly invalidated.
so here is how to do with a vaadin push application behind apache2 proxy :
<VirtualHost *:80>
ServerName yourdomain.tld
ProxyRequests On
ProxyPass / http://localhost:8080/yourApplication/
ProxyPassReverse / http://localhost:8080/yourApplication/
ProxyPassReverseCookiePath /yourApplication /
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>

Redirect apache to tomcat

I am trying to redirect domain.com to tomcat7, I tried a lot of configurations and doesnt seem to work...
This is my /etc/tomcat7/server.xml config
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443"
proxyName="domain.com"
proxyPort="80"
/>
And this is my /etc/apache2/httpd.conf
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
AddModule mod_proxy.c
ProxyPass / http://domain.com:8080/
ProxyPassReverse / http://domain.com:8080/
<Location "/">
Order allow,deny
Allow from all
</Location>
When i go to domain.com i get this default apache message:
It works!
This is the default web page for this server.
The web server software is running but no content has been added, yet.
When i go to domain.com:8080 i get the tomcat message:
It works !
If you're seeing this page via a web browser, it means you've setup Tomcat successfully. Congratulations!
This is the default Tomcat home page. It can be found on the local filesystem at: /var/lib/tomcat7/webapps/ROOT/index.html
I loaded few .WAR with tomcat assistant one is called App1.
If i go to domain.com/App1 i get:
The requested URL /App1/ was not found on this server.
But if i use domain.com:8080/App1 the app works properly and shows a for loop for example.
UPDATE: tried /etc/apache2/ports.conf with this config:
Listen 80
ServerName domain.com
DocumentRoot /var/www/domain.com/public_html
NameVirtualHost IP
UPDATE2: i just wiped out my debian and i just used /etc/apache2/httpd.conf to set this: (only with this file I achieved same result as above, still must use domain.com:8080/appname to run an app...)
<VirtualHost *:8080>
ProxyRequests off
ProxyPreserveHost on
ServerName domain.com
ServerAlias *.domain.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
How can I do it to redirect straight to tomcat default message instead of apaches ?
And how to get rid of that :8080 and make apps work on domain.com/appname
After long time this is tha answer:
Edit file: /etc/apache2/sites-available/default
ServerAdmin webmaster#localhost
ServerName domain.com
DocumentRoot /var/www
ProxyPreserveHost on
ProxyRequests off
ProxyPass /phpmyadmin !
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
using ! to prevent forwarding phpadmin to tomcat

Reverse Proxy Apache DNS error

Upon setting up my test reverse proxy I have encountered this issue:
http://i.imgur.com/Dk7UiOI.png - Sorry can't post images yet...
Below is the apache configuartion.
<virtualhost *:80>
ServerAdmin webmaster#localhost
ServerName localhost
ProxyRequests off
<proxy *>
Order deny,allow
Allow from all
</proxy >
ProxyPass / http://192.168.16.103/
ProxyPassReverse / http://192.168.16.103/
</VirtualHost >
Any have any idea's whats causing this, the redirect comes from a web application on an internal IIS server.
Turns out a reboot of the system solved the issue!

Apache + proxy + tomcat: error - duplicated app name

I have configured an apache 2.2 server to forward requests to a tomcat 6 application listen on 8080/tcp. When the request is processed by apache, it duplicates the name of the application. So an error is posted on the browser.
Apache and tomcat are living at the same server, behind a firewall. On the firewall, I have created a redirect rule to forward all 80/tcp requisitions to apache´s server. 8080 tcp port is blocked on firewall.
Here is my apache 2.2 config:
<VirtualHost *:80>
ServerName myaddress.com
ServerAlias myaddress.com
ServerAdmin webmaster#myaddress.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
Order allow,deny
Allow from all
ProxyPass http://localhost:8080/portal
ProxyPassReverse http://localhost:8080/portal
</Location>
</VirtualHost>
Here is my server.xml config:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" proxyPort="80" proxyName="myaddress.com"/>
When I type http://myaddress.com in the browser, the address is replaced by http://myaddress.com/portal and the following error message is showed:
HTTP Status 404 - /portalportal/
type Status report
message /portalportal/
description The requested resource (/portalportal/) is not available.
It should look like:
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
the "/" means it should be accessed from http://localhost -> proxied to -> http://localhost:8080/portal.
Instead of this you can connect tomcat to apache using workers so that you never have to deal with port 8080, only the apache ones. A good source is http://www3.ntu.edu.sg/home/ehchua/programming/howto/ApachePlusTomcat_HowTo.html
and there are many more guides you can find. So you will have JKmount with the desired path along with your worker name
JkMount /path worker1 for example
Hope I didn't misunderstand your question, and hope it helps!