Before going on, let me say that I'm rather new to application protocols and do not fully understand how this world works ... :-)
This is the situation:
I have several sites being served by apache2.4.7 and those work
well when accessing apache on port 80.
On the other hand, I have only one site being served by tomcat7 and it's
also working well when accessing Tomcat on port 8080.
I tried to redirect traffic from apache on port 80 to that specific site on tomcat on port 8080 and cannot do it (getting a 404 error message).
I have also enabled the proxy and proxy_http modules, but nothing
changed
This is the sites-enabled file for apache:
<VirtualHost 10.10.61.10:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
ServerName 10.10.61.10
<Directory />
Options None
AllowOverride None
</Directory>
Alias /racktables /var/www/racktables/wwwroot/
<Directory /var/www/racktables/wwwroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost 10.10.61.10:80>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /app1/ http://10.10.61.10:8080/app1/
ProxyPassReverse /app1/ http://10.10.61.10:8080/app1/
</VirtualHost>
All the information that I have read only mentioned that adding the above configuration regarding the proxy* parameters nothing more, nothing less.
However, when looking at the access.log of apache, I get the following:
10.10.61.62 - - [10/Nov/2015:11:32:00 -0300] "GET /app1 HTTP/1.1" 404 410 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0"
What is it that I'm missing? Any ideas or hints?
Thanks!
Lucas
Well, after some digging, the solution was to include everything under the same virtualhost such as this:
<VirtualHost 10.10.61.10:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www
ServerName 10.10.61.10
<Directory />
Options None
AllowOverride None
</Directory>
Alias /racktables /var/www/racktables/wwwroot/
<Directory /var/www/racktables/wwwroot>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /app1/ http://10.10.61.10:8080/app1/
ProxyPassReverse /app1/ http://10.10.61.10:8080/app1/
</VirtualHost>
Regards!
Lucas
Related
recently modified httpd.conf and httpd-vhosts.conf to add vhosts...
#IncludeOptional "E:/wamp/vhosts/*"
Include "E:/wamp/alias/*"
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "e:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "e:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName www.projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:/activeWork/projects
ServerName api.projects.local
<Directory "E:/activeWork/projects">
Options Indexes FollowSymLinks
AllowOverride All
Require local
</Directory>
</VirtualHost>
after that when i try to load 192.168.1.6 or 127.0.0.1 , gives me :
Forbidden
You don't have permission to access / on this server.
i've tried to solve it whit this answer but not works for me
and by recommandation in answers i check my access.log and this is the result:
192.168.1.6 - - [03/Oct/2016:11:03:00 +0330] "GET / HTTP/1.1" 403 288
127.0.0.1 - - [03/Oct/2016:11:00:55 +0330] "GET / HTTP/1.1" 403 286
if you are sure that your wamp Installation path is inside E:
then I suggest you to check your access log and error log to collect more information.
I assume you are using Apache 2.4 or later on your Wampserver? If so, then replace the require rules with "Require all granted" in your vhosts, like this:
<VirtualHost *:80>
DocumentRoot "e:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "e:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If it still doesn't work, check if your firewall is blocking your access.
my problem is to define 3 vhost point to same directory and this confused apache...finally tnx to riggsfolly i fixed that...beside of this i make changes from this guide to define VHost to have setup things in a right way
I have a general httpd.conf file that looks like this:
<VirtualHost *:80>
ServerAdmin: me#admin.com
DocumentRoot /var/www/siteone
ServerName: siteone.com
ServerAlias siteone.com
<Directory "var/www/siteone">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin: me#admin.com
DocumentRoot /var/www/sitetwo
ServerName: sitetwo.com
ServerAlias sitetwo.com
<Directory "var/www/sitetwo">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
.... More <VirtualHost>s
Is there anyway I can define one <Location /server-status> and have HTTP requests for all my hosted websites show up on a single mod_status page?
What version of Apache httpd you are using? Though I've not tried but can you give a try with below configuration by defining the multiple 'Require host' inside the '/server-status' location of your httpd.conf file.
<Location "/server-status">
SetHandler server-status
Require host example.com
</Location>
Please note the above configuration is for Apache 2.4.x.
I'm currently migrating a bunch of websites to amazon ec2 (running on the Amazon Linux AMI), and am having difficulties getting Apache's VirtualHost configuration to work.
Here's what my httpd.conf file looks like:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /home/sites/example.com/
<Directory /home/sites/example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/example.com.error.log
LogLevel warn
CustomLog /var/log/httpd/example.com.access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName blog.example.com
DocumentRoot /home/sites/blog.example.com/
<Directory /home/sites/blog.example.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/httpd/blog.example.com.error.log
LogLevel warn
CustomLog /var/log/httpd/blog.example.com.access.log combined
</VirtualHost>
Here's the result of httpd -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443 example.com (/etc/httpd/conf.d/ssl.conf:74)
*:80 is a NameVirtualHost
default server example.com (/etc/httpd/conf/httpd.conf:1012)
port 80 namevhost example.com (/etc/httpd/conf/httpd.conf:1012)
port 80 namevhost blog.example.com (/etc/httpd/conf/httpd.conf:1029)
Syntax OK
However, if I attempt to go to blog.example.com, I get a ERR_NAME_NOT_RESOLVED response.
If I change the first VirtualHost definition to blog.example.com, I can load the blog.example.com site, so both sites are working, leading me to suspect I either have configured something wrong in VirtualHost, or on the end of my domain registrar.
My issue was that I had the example.com domain before the blog.example.com domain, meaning everything just went to example.com. Order matters!
I wolud like to use virtual host on Apache 2.4
I use Xampp and I will have more site so on it.
I have already read some guide and I have edit my httpd.config
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
and the Load
also my defalut port in busy, so I have set
Listen 8080
After that I edit my httpd-vhosts.conf in this way
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:8080>
ServerName sample.locl
DocumentRoot "C:\wwww\sample"
<Directory "C:\wwww\sample">
DirectoryIndex index.php
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName sample2.locl
DocumentRoot "C:\wwww\sample2"
<Directory "C:\wwww\sample2">
DirectoryIndex index.php
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
N.B. my site is in C:/www/sample and c:/www/sample2 and my xampp in in c:/xampp.
At the end I edit my host in system32 with
127.0.0.1 localhost
127.0.0.1 sample
127.0.0.1 sample2
Now I have 404 error, neither when I wrote: "localhost" in my url browser.
If i Understand how it work I suppose that when i write localhost it will be redirect to C:\xampp\htdocs and so I should see my xampp page but it's not so.. where did I go wrong?
I always recive
Not Found
HTTP Error 404. The requested resource is not found.
thanks in advance
I'm trying to serve up two different Django apps on two separate ports. I have app1 on port 80 and app2 on port 8080. So what I'm expecting is that when I put example.com:80 into my browser, my request should get served up from app1, and when I put example.com:8080 into my browser, my request should get served up from app2. However, sometimes it will serve up my request from the wrong app. Then, after a few refreshes, it will sometimes switch. What's more, sometimes it will serve up from the correct app and then, after a few refreshes, switch to the wrong one. I know this isn't due to caching on the browser's end because I've also tried sending requests with curl from the machine and I get the same behavior. I can't understand why I'm getting this unexpected, nondeterministic behavior.
Here is my VirtualHost configuration:
<VirtualHost *:80>
ServerAlias *
ServerPath /app1/
WSGIScriptAlias /app1 /home/eyuelt/app1/app1/wsgi.py
Alias /app1/static /home/eyuelt/app1/staticfiles
<Directory /home/eyuelt/app1/app1>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app1/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Listen 8080
<VirtualHost *:8080>
ServerAlias *
ServerPath /app2/
WSGIScriptAlias /app2 /home/eyuelt/app2/app2/wsgi.py
Alias /app2/static /home/eyuelt/app2/staticfiles
<Directory /home/eyuelt/app2/app2>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/eyuelt/app2/staticfiles>
AllowOverride None
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
I suspect this might be the problem:
http://httpd.apache.org/docs/2.2/vhosts/examples.html
This is what you want: You have multiple domains going to the same IP
and also want to serve multiple ports. By defining the ports in the
"NameVirtualHost" tag, you can allow this to work.
One or both of these could be the problem: If you try using
without the NameVirtualHost name:port or you
try to use the Listen directive, your configuration will not work.
Server example:
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot /www/domain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot /www/domain-8080
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot /www/otherdomain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>