Apache proxy forward wildcard subdomain to tomcat - apache

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>

Related

Apache2 and Graylog

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>

Multiple domains mixed up with SSL configuration with Apache httpd

I have two domains and 1 IP address. In my httpd.conf file, I added,
<VirtualHost *:80>
ServerName www.domain1.com
ServerAlias domain1.com
Redirect permanent / https://www.domain1.com/
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain2.com
ServerAlias domain2.com
Redirect permanent / https://www.domain2.com/
</VirtualHost>
There are some cases that domain2 URLs are redirected to domain1 (pay attention to the url protocols).
For example, on iPhone/Safari,
http://www.domain2.com
http://domain2.com
will both be redirected to https://www.domain1.com
On Windows using MSIE,
http://domain2.com
will both be redirected to https://www.domain1.com
http://www.domain2.com works fine.
On Windows using Chrome, most of the cases work except,
https://domain2.com will be considered insecure.
So this looks like a browser problem. Is there a way to prevent this from happening reliably?
Thanks.
You can do this (it works for me):
<VirtualHost *:80>
ServerName example1.com
ServerAlias example1.com
ProxyRequests off
ProxyPass / http://127.0.0.1:9090/
ProxyPassReverse / http://127.0.0.:9090/
</VirtualHost>
<VirtualHost *:80>
ServerName example2.com
ServerAlias example2.com
ProxyRequests off
ProxyPass / http://127.0.0.1:9091/
ProxyPassReverse / http://127.0.0.1:9091/
</VirtualHost>

Virtualhost For Wildcard and Static Subdomain

This is what I basically have now:
<VirtualHost *:80>
DocumentRoot /var/www/app1
ServerName app1.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/example
ServerName example.com
ServerAlias *.example.com
</VirtualHost>
This configuration makes app1.example.com a default serving VirtualHost.
Thus, when another.domain.com is pointed to *.example.com, it is served by app1.example.com.
How this configuration can be changed, so that another.domain.com would be served by *.example.com, still having app1.example.com, *.example.com and example.com working too?
Thank you.
P.S. I'm basing somewhat my question on this SO answer
My own research gave me the only workaround so far. I've ended up using another port for app1.example.com.
<VirtualHost *:8080>
DocumentRoot /var/www/app1
ServerName app1.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/example
ServerName example.com
ServerAlias *.example.com
</VirtualHost>

What's wrong with this simple SSL Vhost declaration?

Any reason why the middle vhost setting is causing an issue w/ Apache? Maybe it's because I don't have the SSL details in there?
<VirtualHost *:80>
ServerName www.windfarmstudios.com
ServerAlias windfarmstudios.com
Redirect permanent / https://windfarmstudios.com
</VirtualHost>
#<VirtualHost *:443>
# ServerName www.windfarmstudios.com
# Redirect permanent / https://windfarmstudios.com
#</VirtualHost>
<VirtualHost *:443>
ServerName windfarmstudios.com
DocumentRoot /var/www/windfarmstudios.com/public_html
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/windfarm.crt
SSLCertificateKeyFile /etc/apache2/ssl/windfarm.key
SSLCACertificateFile /etc/apache2/ssl/windfarm.ca-bundle
</VirtualHost>

Apache VirtualHost - domain name

I bought a domain name, one with ".fr" and the other one with ".com"
Now I want to redirect my domaine name to a server running on the port 4000.
For that I used virualhost:
<VirtualHost *:80>
ServerName http://www.example.fr
ServerAlias example.fr
ProxyRequests Off
ProxyVia On
ProxyPass / http://localhost:4000/
ProxyPassReverse / http://localhost:4000/
ErrorLog logs/error_log
CustomLog logs/access_log common
</VirtualHost>
It works fine when I access ".com" but doesn't work with the ".fr".
Any idea ? thx
Change ServerName and ServerAlias to:
ServerName example.fr
ServerAlias www.example.fr example.com www.example.com