i need to solve quickly this problem.
I have a apache2 running on server and a graylog installed and running and i cannot reach the localhost:9000 where the graylog is running. I try to configure virtualhost, but i can't configure correctly.
i try this config, and many others, but no one help me.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.graylog.xxxxxx.com
ServerAlias example.com
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.graylog.xxxxxx.com
ServerAlias example.com
ProxyPass / http://127.0.0.1:9000/
ProxyPassReverse / http://127.0.0.1:9000/
</VirtualHost>
Related
My server hosts two web services: WordPress(on Port 8080) and Flask(on Port 8081). I am setting up a reverse proxy as I want any requests start with /admin goes to Flask and all others go to Wordpress.
For example:
http://aa.mcmaster.ca/admin/aa Goes to Port 8080
http://aa.mcmaster.ca/page1 Goes to Port 8081
http://aa.mcmaster.ca/page1 Goes to Port 8081
My setting is:
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /admin http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin http://aa.mcmaster.ca:8080/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/
</VirtualHost>
It doesn't work. I am stuck on how to set up to matchs requests other than /admin. Can I get some help?
Thanks!
Use below ProxyPass in a single VirtualHost and test.
ProxyPass /admin/ http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin/ http://aa.mcmaster.ca:8080/
ProxyPass / http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/
I have two project that write with spring boot, and have separate port number.
server.port: 23100
server.port: 23101
now, I want to deploy the two project into one server and shard the same port 80,
How should I do to support this case ?
I know it can use Apache Http Server to support PHP etc. how to do this will Spring Boot ?
Update
thanks #HeadBangingSloth give this solution, general idea is to redirect 80 port to local port number according to domain name.
create vhost.conf file in /etc/httpd/conf.d/ folder
add following content according to your real case.
restart http server via service httpd restart
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.app1.com
ServerAlias app1.com
ProxyPass / http://localhost:23100/
ProxyPassReverse / http://localhost:23100/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.app2.com
ServerAlias app2.com
ProxyPass / http://localhost:23101/
ProxyPassReverse / http://localhost:23101/
</VirtualHost>
I would suggest looking at this question here Apache redirect to another port
If you deploy your applications to your sever, you can set up your VirtualHosts in Apache to pass the incoming connections along
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.app1.com
ServerAlias app1.com
ProxyPass / http://localhost:23100/
ProxyPassReverse / http://localhost:23100/
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.app2.com
ServerAlias app2.com
ProxyPass / http://localhost:23101/
ProxyPassReverse / http://localhost:23101/
</VirtualHost>
How do I setup the virtual host to forward the subdomin part to my tomcat.
I know * does not work....but how do I achieve something as below.
<VirtualHost *:80>
ProxyPreserveHost On
ServerName *.example.com
ProxyPass /app1 *.localhost:8080/app1
</VirtualHost>
Well that was a stupid question, the
ProxyPreserveHost On
by itself will preserve the original request so I don't have to forward the subdomain.
just the below will work..
<VirtualHost *:80>
ProxyPreserveHost On
ServerName *.example.com
ProxyPass /app1 http://localhost:8080/app1
</VirtualHost>
and my code actually sees http://subdomain.example.com/app1
Use one specific servername (perhaps "dummy"), then use the wildcard in a
ServerAlias statement:
<VirtualHost *:80>
ProxyPreserveHost On
ServerName dummy.example.com
ServerAlias *.example.com
ProxyPass /app1 *.localhost:8080/app1
</VirtualHost>
I'm trying to run two different web application on the same server, with the same domain name, like :
www.example.com/app1
www.example.com/app2
The applications are developed using Play! framework, and I'm using Apache as a reverse proxy. I tried to follow the online guide, set up the virtual host and etc..., but nothing seem to works, only the first app is reacheble, while the second isn't.
This is as far as I got untill now with my apache config file :
<VirtualHost *:80>
ProxyPreserveHost On
DocumentRoot "/home/App1/"
ServerName http://www.example.com/app1
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:9000/app1
ProxyPassReverse / http://127.0.0.1:9000/app1
LogLevel debug
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
DocumentRoot "/home/App2"
ServerName http://www.example.com/app2
ProxyPass /excluded !
ProxyPass / http://127.0.0.1:8000/app2
ProxyPassReverse / http://127.0.0.1:8000/app2
LogLevel debug
</VirtualHost>
Route, code and everithing are correct, it's just that I can't get these apps work together.
(I also tried to implement the load balacer showed on the online guide, but it didn't work)
Thanks.
I don't think you can have two virtual hosts with the same host name - that doesn't make sense, virtual hosts are for serving different host names, for example, for serving foo.example.com and bar.example.com.
I think what you want is something roughly like this:
<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.example.com
DocumentRoot /some/path/to/something
ProxyPass /excluded !
ProxyPass /app1 http://127.0.0.1:9000/app1
ProxyPassReverse /app1 http://127.0.0.1:9000/app1
ProxyPass /app2 http://127.0.0.1:8000/app2
ProxyPassReverse /app2 http://127.0.0.1:8000/app2
LogLevel debug
</VirtualHost>
James' answer is correct, you just need to fit it to your needs, I shoot that works out of the box:
<VirtualHost *:80>
ProxyPreserveHost On
ServerName www.example.com
ProxyPass /app1 http://127.0.0.1:9000/
ProxyPassReverse /app1 http://127.0.0.1:9000/
ProxyPass /app2 http://127.0.0.1:8000/
ProxyPassReverse /app2 http://127.0.0.1:8000/
</VirtualHost>
Note, that you will need to prefix EVERY route in your apps to reflect the folder path with app1 and app2, like:
foo site
bar site
I am looking to achieve this configuration. So I tried this but the server is allways looking for server_test and server_prod in the htdocs under Apache. What I want is to redirect the request to the Tomcat server. If I use different ports without the /server_test and /server_prod, it worked but it's not what I wanted.
<virtualhost mydomaine.com/server_test:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8008/
ProxyPassReverse / http://mydomaine.com/server_test/
ProxyPassReverseCookiePath / /
</virtualhost>
<virtualhost mydomaine.com/server_prod:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8009/
ProxyPassReverse / http://mydomaine.com/server_prod/
ProxyPassReverseCookiePath / /
</virtualhost>
Any help would be appreciated
Try this:
<virtualhost mydomaine.com:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass /server_test ajp://internalIp:8008/
ProxyPass /server_prod ajp://internalIp:8009/
ProxyPassReverse /server_test ajp://internalIp:8008/
ProxyPassReverse /server_prod ajp://internalIp:8009/
</virtualhost>
However, you would not be able to use ProxyPassReverseCookiePath, because both Tomcat sites would set cookies with / as the path.
To make it work as I believe you want, you need to have two separate VirtualHosts. If you only have one IP address, you need to use name-based virtual hosts.
For example, add a subdomain test.mydomaine.com that has the same IP address as mydomaine.com. Then use this configuration:
NameVirtualHost mydomaine.com:80
<virtualhost mydomaine.com:80>
ServerName mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8009/
ProxyPassReverse / ajp://internalIp:8009/
</virtualhost>
<virtualhost mydomaine.com:80>
ServerName test.mydomaine.com
ProxyRequests Off
ProxyPass / ajp://internalIp:8008/
ProxyPassReverse / ajp://internalIp:8008/
</virtualhost>
You can then access your production site at http://mydomaine.com/ and your test site at http://test.mydomaine.com/.