I'm trying to enable a service on my home server that has a different document root than my main site. I can't figure out how to edit the site .conf files so that I can run both the main site and the new service.
My use case: I've got a home server running Ubuntu 16.04.1 and Apache 2. I can browse to my site at ceres.local. I also installed OpenProject 6.1. After the install completes, I can browse to that service at ceres.local/openproject, but now browsing to ceres.local returns a 403 Forbidden.
I checked my sites-enabled, and I see that the 000-default.conf is no longer listed, just openproject.conf. So, I ran a2ensite 000-default.conf and service apache2 reload. Now, I can browse to ceres.local, but ceres.local/openproject returns a 404 Not Found.
How do I get both 'ceres.local' and 'ceres.local/openproject' to serve properly with the two .conf files below? Note the different document roots.
My 000-default.conf reads as follows:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
ServerName ceres.local
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And my openproject.conf reads as follows:
Include /etc/openproject/addons/apache2/includes/server/*.conf
<VirtualHost *:80>
ServerName ceres.local
DocumentRoot /opt/openproject/public
ProxyRequests off
Include /etc/openproject/addons/apache2/includes/vhost/*.conf
ProxyPass /openproject/ http://127.0.0.1:6000/openproject/ retry=0
ProxyPassReverse /openproject/ http://127.0.0.1:6000/openproject/
</VirtualHost>
I know is a very old post.
But I spend 3 days to solve this and is a first post when we google
so, when you install openproject he create a file called openproject.conf and disable the 000-default.conf
inside this file are a configuration like this
Include /etc/openproject/addons/apache2/includes/server/*.conf
<VirtualHost *:80>
ServerName mydomain.com
DocumentRoot /opt/openproject/public
ProxyRequests off
Include /etc/openproject/addons/apache2/includes/vhost/*.conf
# Can't use Location block since it would overshadow all the other
#Proxypass directives on CentOS
ProxyPass /help/ http://127.0.0.1:6000/help/ retry=0
ProxyPassReverse /help/ http://127.0.0.1:6000/help/
</VirtualHost>
but when you try acess the mydomain.com you receive the message 403 - forbitten
you just need modify the file like this
Include /etc/openproject/addons/apache2/includes/server/*.conf
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias www.mydomain.com
DocumentRoot /var/www/html # <----- LOCATION WHERE YOU SITE ARE
#DocumentRoot /opt/openproject/public #<--- You Need comment this line
ProxyRequests off
Include /etc/openproject/addons/apache2/includes/vhost/*.conf
# Can't use Location block since it would overshadow all the other proxypass
directives on CentOS
ProxyPass /help/ http://127.0.0.1:6000/help/ retry=0
ProxyPassReverse /help/ http://127.0.0.1:6000/help/
So, if can see the proxypass below, apache will redirect to then when you put mydomain.com/help (you be redirect to openproject), mydomain.com (you main site )
I Hope with this help someone
Be Happy :)
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.
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.
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>
I've struggled with this for some time and am definitely doing something wrong.
I have Apache server and a JBoss server on the same machine. I'd like to redirect traffic for mydomain.example to JBoss localhost:8080/example. The DNS is currently setup for mydomain.example and it will go straight to port 80 when entered into the browser.
My question is how do I redirect to a different port when a certain domain name comes to Apache (in this case, mydomain.example)?
<VirtualHost ip.addr.is.here>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.example
ProxyPass http://mydomain.example http://localhost:8080/example
ProxyPassReverse http://mydomain.example http://localhost:8080/example
</VirtualHost>
After implementing some suggestions:
Still not forwarding to port 8080
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.example
ServerAlias www.mydomain.example
ProxyPass http://mydomain.example http://localhost:8080/example
ProxyPassReverse http://mydomain.example http://localhost:8080/example
</VirtualHost>
You should leave out the domain http://example.com in ProxyPass and ProxyPassReverse and leave it as /. Additionally, you need to leave the / at the end of example/ to where it is redirecting. Also, I had some trouble with http://example.com vs. http://www.example.com - only the www worked until I made the ServerName www.example.com, and the ServerAlias example.com. Give the following a go.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:8080/example/
ProxyPassReverse / http://localhost:8080/example/
</VirtualHost>
After you make these changes, add the needed modules and restart apache
sudo a2enmod proxy && sudo a2enmod proxy_http && sudo service apache2 restart
I solved this issue with the following code:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName myhost.example
ServerAlias www.myhost.example
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
I also used:
a2enmod proxy_http
I wanted to do exactly this so I could access Jenkins from the root domain.
I found I had to disable the default site to get this to work. Here's exactly what I did.
$ sudo vi /etc/apache2/sites-available/jenkins
And insert this into file:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName mydomain.example
ServerAlias mydomain
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
Next you need to enable/disable the appropriate sites:
$ sudo a2ensite jenkins
$ sudo a2dissite default
$ sudo service apache2 reload
Found this out by trial and error. If your configuration specifies a ServerName, then your VirtualHost directive will need to do the same. In the following example, awesome.example.com and amazing.example.com would both be forwarded to some local service running on port 4567.
ServerName example.com:80
<VirtualHost example.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName awesome.example.com
ServerAlias amazing.example.com
ProxyPass / http://localhost:4567/
ProxyPassReverse / http://localhost:4567/
</VirtualHost>
I know this doesn't exactly answer the question, but I'm putting it here because this is the top search result for Apache port forwarding. So I figure it'll help somebody someday.
This might be an old question, but here's what I did:
In a .conf file loaded by Apache:
<VirtualHost *:80>
ServerName something.com
ProxyPass / http://localhost:8080/
</VirtualHost>
Explanation: Listen on all requests to the local machine's port 80. If I requested "http://something.com/somethingorother", forward that request to "http://localhost:8080/somethingorother". This should work for an external visitor because, according to the docs, it maps the remote request to the local server's space.
I'm running Apache 2.4.6-2ubuntu2.2, so I'm not sure how the "-2ubuntu2.2" affects the wider applicability of this answer.
You have to make sure that the proxy is enabled on the server. You can do so by using the following commands:
a2enmod proxy
a2enmod proxy_http
service apache2 restart
If you don't have to use a proxy to JBoss and mydomain.example:8080 can be "exposed" to the world, then I would do this.
<VirtualHost *:80>
ServerName mydomain.example
Redirect 301 / http://mydomain.example:8080/
</VirtualHost>
Just use a Reverse Proxy in your apache configuration (directly):
ProxyPass /foo http://foo.example.com/bar
ProxyPassReverse /foo http://foo.example.com/bar
Look here for apache documentation of how to use the mod
My apache listens to 2 different ports,
Listen 8080
Listen 80
I use the 80 when i want a transparent URL and do not put the port after the URL
useful for google services that wont allow local url?
But i use the 8080 for internal developing where i use the port as a reference for a "dev environment"
You need 2 things:
Add a ServerAlias www.mydomain.example to your config
change your proxypass to ProxyPassMatch ^(.*)$ http://localhost:8080/example$1, to possibly keep mod_dir and trailing slashes from interfering.
Apache supports name based and IP based virtual hosts. It looks like you are using both, which is probably not what you need.
I think you're actually trying to set up name-based virtual hosting, and for that you don't need to specify the IP address.
Try < VirtualHost *:80> to bind to all IP addresses, unless you really want ip based virtual hosting. This may be the case if the server has several IP addresses, and you want to serve different sites on different addresses. The most common setup is (I would guess) name based virtual hosts.
This is working in ISPConfig too. In website list get inside a domain, click to Options tab, add these lines: ;
ProxyPass / http://localhost:8181/
ProxyPassReverse / http://localhost:8181/
Then go to website and wolaa :) This is working HTTPS protocol too.
Try this one-
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.adminbackend.example.com
ServerAlias adminbackend.example.com
ProxyPass / http://localhost:6000/
ProxyPassReverse / http://localhost:6000/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This is how I redirected part of the requests to one url and rest to another url:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName localhost
ProxyPass /context/static/content http://localhost:80/web/
ProxyPassReverse /context/static/content http://localhost:80/web/
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
All are excellent insights to accessing ports via domain names on virtual servers. Do not forget, however, to enable virtual servers; this may be commented out:
NameVirtualHost *:80
<Directory "/home/dawba/www/">
allow from all
</Directory>
We run WSGI with an Apache server at the domain sxxxx.com and a golang server running on port 6800. Some firewalls seem to block domain names with ports. This was our solution:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName wsgi.sxxxx.example
DocumentRoot "/home/dxxxx/www"
<Directory "/home/dxxx/www">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /py/ "/home/dxxxx/www/py/"
WSGIScriptAlias /wsgiprog /home/dxxxx/www/wsgiprog/Form/Start.wsgi
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName sxxxx.com
ServerAlias www.sxxxx.com
ProxyPass / http://localhost:6800/
ProxyPassReverse / http://localhost:6800/
</VirtualHost>