I'm having trouble with making a subdomain to my Windows computer while using AJP to proxy to Tomcat. This is what I have in my httpd.conf file:
<VirtualHost *:80>
ServerName subdomain.localhost
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / ajp://localhost:8009/folder/
ProxyPassReverse / ajp://localhost:8009/folder/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
The subdomain has been added to `c:\windows\system32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 subdomain.localhost
When I go to http://localhost i goes straight to the proxy. When I go to http://subdomain.localhost i goes to the proxy as well. How do I make is so the subdomain only goes to the proxy and the regular goes to Apache?
You need to declare a second VirtualHost with localhost as the ServerName.
This should probably be moved to superuser.com but one thing to try:
<VirtualHost *:80> informs it to accept all incoming connections on port 80 to use these settings. I would try changing it to say:
<VirtualHost subdomain.localhost:80>
and see if that only applies these settings when the subdomain is used.
The ServerName tag that you put with the subdomain doesn't tell it who to listen for. The official documentation states:
The ServerName directive sets the
hostname and port that the server uses
to identify itself. This is used when
creating redirection URLs. For
example, if the name of the machine
hosting the web server is
simple.example.com, but the machine
also has the DNS alias www.example.com
and you wish the web server to be so
identified, the following directive
should be used:
You can read more on these configurations here.
Related
hi guys i wanna ask about apache mod_proxy.
really try hard to find how to convert url adress but no result yet.
so here is problem.
request URL and service URL: www.mbc.com:10800
i want to show browser adress bar like this 'www.mbc.com'
webserver : linux + apache and virtualhost.
httpd.conf
<VirtualHost *:10800>
ProxyRequests Off
ProxyPreserveHost On
SSLEngine on
<Proxy *>
Order Deny,Allow
Allow from all
</Proxy>
ProxyPass / https://www.mbc.com:10800/
ProxyPassReverse / https://www.mbc.com/
</VirtualHost>
this configuration is not working. which configuration changed?
The port is shown in the URL bar if it is not the standard port. To make it vanish you need to use the standard port for your server, i.e. 80 for http and 443 for https:
<VirtualHost *:80>
I'm already using mod_proxy to redirect from example-domain.com to example-domain.com:8080, well without CloudFlare (reserve proxy) it works... but with CloudFlare it just response an error 1000 DNS points to prohibited IP. Any chances to get trough this and still use CloudFlare to protect myself? I don't want that the address show something like this with mod_rewrite http://example-domain.com:8080, that's why I'm redirecting, hosting on port 80 is impossible so no changes there.
My vhost config:
<Directory /var/www/example-domain.com>
AllowOverride None
Require all denied
</Directory>
<VirtualHost *:80>
DocumentRoot /var/www/example-domain.com/web
ServerName example-domain.com
ServerAlias www.example-domain.com
ServerAlias alias.example-domain.com
ServerAdmin webmaster#example-domain.com
ProxyPreserveHost On
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://example-domain.com:8080/
ProxyPassReverse / http://example-domain.com:8080/
</VirtualHost>
Regardless of what port you are accessing CloudFlare through, CloudFlare has a tendency to try port 80/443 first. If it can connect to these ports during it's own proxying it stops there and then does not try the port you actually wanted (in your case 8080).
Therefore this looks like a cyclic loop, you are pointing your requests from CloudFlare to proxy to point back through CloudFlare to the server at port 8080. CloudFlare is then stripping the port 8080 and connecting via a plain connection.
The best way to fix this is to simply to set your ProxyPass to go through a URL that doesn't run through the CloudFlare network or simply through localhost.
So either change the ProxyPass in your VirtualHost to:
ProxyPass / http://direct.example-domain.com:8080/
ProxyPassReverse / http://direct.example-domain.com:8080/
Where direct.example-domain.com does not route through the CloudFlare network (a grey cloud in your CloudFlare DNS, providing you're doing a full-host CloudFlare set-up).
Alternatively change your proxy pass to go via the localhost:
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
Have fun!
I have a web site on EC2 running with tomcat(8080), and in the same instance I have apache2 (80) to give statical files (image) to a android app. I need both, but it's not neccesary that it collaborate.
Well, my question is if I have this url : http://ec2-54-72-116-252.eu-west-1.compute.amazonaws.com:8080/OcioTurismoMontoro
How can I redirect my www.montoroturismo.tk to it?
In the domain panel I only can put the ip of my hosting but neither the port either the context (/OcioTurismoMontoro) .
Please, help me.
You will have to manage port forwarding on the instance itself. If you want to serve something else on port 80, may be you can create virtual host on Apache. Put this in <Apache>/conf/sites-enabled/OcioTurismoMontoro.conf:
<virtualhost *:80>
ServerAdmin webmaster#localhost
ServerName www.montoroturismo.tk
ProxyRequests off
<proxy *>
Order deny,allow
Allow from all
</proxy>
ProxyPass / http://127.0.0.1:8080/OcioTurismoMontoro/
ProxyPassReverse / http://127.0.0.1:8080/OcioTurismoMontoro/
</VirtualHost>
You will need mod proxy for Apache.
Can you help me? I have two servers with all permissions in CentOS, assigned IPs, and a subdomain that pointing to one, where there a static website. But, the other server has a blog on Wordpress. The question is how pointing from a folder to another server. Thus:
subdomain.domain.com >> IP: 1.2.3.4
subdomain.domain.com/blog >> ANOTHER: 2.3.4.5
Your best bet is to use something like mod_proxy to reverse proxy requests for blog related resources to your WordPress Server.
So something like:
<VirtualHost *:80>
ServerName subdomain.domain.com
DocumentRoot /whatever
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /blog http://2.3.4.5/blog
ProxyPassReverse /blog http://2.3.4.5/blog
#...
</VirtualHost>
One more point to mention, in the example above I reverse proxying to a resource identified by the hosts IP address. I would strongly recommend using a hostname and DNS instead since DNS is a good thing:
ProxyPass /blog http://blog.domain.com/blog
ProxyPassReverse /blog http://blog.domain.com/blog
Obviously you''l need to add 2.3.4.5 to DNS (or host hack accordingly)
I have two applications, one is the www.myexample.com, another is the blog.myexample.com. I am using PHP and Apache.
Now, I want to let www.myexample.com runs on port 82 of my machine, and blog.myexample.com on port 83, on the same machine. How to configure the apache and/ or the PHP scripts so that when the requests for the requests are served properly?
Edit: Thanks for everyone who responds, but I afraid I don't get the question clear-- my bad!
What I really want is to simulate a condition whereby the www.myexample.com and blog.myexample.com are located on different machines. So when a request comes in, the gateway server ( the one which is also hosting www.myexample.com) will check whether this is a request for www.myexample.com or for blog.myexample.com and does the necessary reroutes.
How to do this? Thanks.
I will assume that you have your own reason for wanting the two sites (www and blog) to run on different ports - and in different processes. If this is not what you intended, e.g. you did not want to have two distinct processes, then having different ports may not be what you intended either: use VirtualHost instead, to co-host the two domains within the same apache+php instance on port 80. Otherwise, read on.
Assuming that you have your two apache+php processes listening on localhost:82 and localhost:83 respectively, bring up a third, apache-only process to act as a reverse proxy. Have the reverse proxy apache instance listen for requests coming on port 80 from the internet, with two virtual host definitions. The first virtual host definition, www, would forward requests to localhost:82, whereas the second virtual host definition, blog, would forward requests to locahost:83, e.g.:
NameVirtualHost *:80
# www
<VirtualHost *:80>
ServerName www.myexample.com
ProxyPass / http://localhost:82/
ProxyPassReverse / http://localhost:82/
</VirtualHost>
# blog
<VirtualHost *:80>
ServerName blog.myexample.com
ProxyPass / http://localhost:83/
ProxyPassReverse / http://localhost:83/
</VirtualHost>
I use proxy for this type of things.
In my example, I have apache 1.3 running on port 80, but I needed svn repository to run on apache 2.2, and I didn't want to type :82 on the end of the domain every time. So I made proxy redirection on apache 1.3 (port 80):
<VirtualHost *:80>
ServerName svn.mydomain.com
ServerAlias svn
ServerAdmin my#email.com
<IfModule mod_proxy.c>
ProxyPass / http://svn:82/
</IfModule>
</VirtualHost>
Run the following line on terminal (specify your domain and sub domain name correctly)
sudo nano /etc/apache2/sites-available/subdomain.domain.com.conf
Paste the following code and change as your requirement
<VirtualHost *:80>
ServerAdmin admin#domain.com
ServerName subdomain.domain.com
ServerAlias subdomain.domain.com
ProxyRequests Off
#ProxyPass / http://localhost:8080/
<Location />
ProxyPreserveHost On
ProxyPass http://domain.com:8080/
ProxyPassReverse http://domain.com:8080/
</Location>
# Uncomment the line below if your site uses SSL.
#SSLProxyEngine On
</VirtualHost>
Run the following lines on terminal (specify your domain and sub domain name correctly)
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod subdomain.domain.com.conf
sudo service apache2 restart
Off the top of my hat:
Listen 82
Listen 83
NameVirtualHost 1.2.3.4 # Use your server's IP here
<VirtualHost www.myexample.com:82>
# Configure www.myexample.com here
</VirtualHost>
<VirtualHost blog.myexample.com:83>
# Configure blog.myexample.com here
</VirtualHost>
A more complete answer to this would be to do something like this which allow you to setup a proxy gateway which is what is loosly described above.
ServerName localhost
<Proxy *>
Order deny,allow
Allow from localhost
</Proxy>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:10081/
ProxyPassReverse / http://localhost:10081/
ProxyPassReverseCookiePath / http://localhost:10081/