I have apache2 and tomcat7 in /var/lib/tomcat7. I have my two apps in tomcat webapps: app1 and app2. I have configured my apache virtual host as below:
#
<VirtualHost *:80>
ServerName myweb1.com
ProxyRequests Off
ProxyPass / http://localhost:8080/web1/
ProxyPassReverse / http://localhost:8080/web1/
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
#
myweb1.com is running in a browser but when I make another vhost for web2, myweb2.com is not loading. Yet when I do myweb2:8080/web2 in my browser it's loading the page. What could be the reason for this? Note that myweb2.com has no problem with DNS entry.
I have tried to put web2 into /opt/tomcat9/webapps but the same results come.
Related
I have an elastic load balancer which direct all the requests at port 80 to my ec2 instance where i have apache installed and i have defined the main server configuration and a virtual host.
But all request are served by the main server defined in apache httpd.conf file.
my apache configuration is having following details:
DocumentRoot "/var/www/html" - for main server
And for sub domain requests:
<VirtualHost p2.neptunetimesheets.com:80>
ServerAdmin webexpertsujeet#gmail.com
DocumentRoot "/var/www/neptunev2"
ServerName p2.neptunetimesheets.com
#ServerAlias p1.neptunetimesheets.com
<Directory "/var/www/neptunev2">
Require all granted
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine On
</VirtualHost>
Is it due to the load balancer that is causing this issue ?
I am taking over a multi-site Apache server, with two websites (A and B). Going to website A's url via http works fine. Going to the same url, but using https, shows website B. Why is this, and how do I make https://urlA.com go to website A?
I solved the problem.
The servers were set up with VirtualHosts, but there was no VirtualHost for port 443. So it looked something like this:
<VirtualHost 99.9.9.999:80>
DocumentRoot /var/www/example
ServerName example.com
<Directory "/var/www/example">
Options Indexes
AllowOverride None
DirectoryIndex index.php index.html
Order allow,deny
Allow from all
</Directory>
Adding a VirtualHost listening on port 443, with the SSLCertFiles specified fixed the problem.
<VirtualHost 99.9.9.999:443>
DocumentRoot /var/www/example
ServerName example.com
<Directory "/var/www/example">
Options Indexes
AllowOverride None
DirectoryIndex index.php index.html
Order allow,deny
Allow from all
</Directory>
SSLCertificateFile /etc/httpd/conf/example.crt
SSLCertificateKeyFile /etc/httpd/conf/_.example.key
SSLCertificateChainFile /etc/httpd/conf/gd_example.crt
SSLEngine on
</VirtualHost>
I have a web-service that I would like to expose through the URL foo.com/bar.
However my Apache reverse proxy does not work as intended.
I have created the file 001-default.conf, which contains the following code:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /bar http://foo.com:8080/bar
ProxyPassReverse /bar foo.com:8080/bar
DocumentRoot /var/www/foo/
ServerName info.foo.com
<Directory /var/www/foo>
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Right now I receive a 404 error code.
I want to achieve all hits on foo.com/bar to be silently redirected to foo.com:8080/bar, meaning that the user should only see the URL foo.com/bar.
The reverse proxy redirect should also include requests such as foo.com/bar?=foobar.
I did enable proxy_http and proxy:
% sudo a2enmod proxy_http
Considering dependency proxy for proxy_http:
Module proxy already enabled
Module proxy_http already enabled
I hope that there is someone out there that are able to help me with this.
Similar problem that did not solve my problem:
apache reverse proxy changes url Transparent redirect to port 8080
Try and edit the config to:
<VirtualHost *:80>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /bar http://foo.com:8080 # Note removed /bar
ProxyPassReverse /bar foo.com:8080 # Note removed /bar
DocumentRoot /var/www/foo/
ServerName info.foo.com
<Directory /var/www/foo>
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
You can also try with mod_alias to avoid te /bar/bar issue you might be facing now.
I do not know much about it, see the documentation: http://httpd.apache.org/docs/2.2/mod/mod_alias.html
Try something like adding this to your conf
Alias /bar http://foo.com:8080
Using this you might wan't to remove the proxy.
I have two subdomains on my VPS, i have registered the two subdomains in my DNS pointing to the same IP address.
the version installed is Server version: Apache/2.4.7 for Ubuntu 12.04.
I've enabled the sites with the a2ensite command and i have enable the module vhost_alias. restart and reloaded many times
stable.mydomain.com
<VirtualHost *:80>
ServerName stable.mydomain.com
DocumentRoot /var/www/stable/web
<Directory /var/www/stable/web>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>
beta.mydomain.com
<VirtualHost *:80>
ServerName beta.mydomain.com
DocumentRoot /var/www/beta/web
<Directory /var/www/beta/web>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
Allow from all
</Directory>
</VirtualHost>
my trouble is pointing my browser to any url always i get the same content and to add more confusion when i execute service apache2 reload in the two subdomains i get the content from beta.mydomain.com and when execute service apache2 restart in the two subdomains i get the content of stable.mydomain.com.
I have spent about 5 hours trying to fix this
update
event i try with the VirtualDocumentRoot
<Virtualhost *:80>
VirtualDocumentRoot "/var/www/%1/web"
ServerName stable.mydomain.com
ServerAlias *.mydomain.com
UseCanonicalName Off
<Directory "/var/www/*">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</Virtualhost>
with the same behavior explained before this update
Have you uncommented this line before defining the virtual hosts?
NameVirtualHost *:80
I have an internal web server (192.168.1.2) that manage multiple domains.
Now i need to put in DMZ one more server, acting as reverse proxy (it's an Apache 2.2.3, with IP 192.168.1.3 and one more interface with static internet IP)
I need this Apache server should proxy any domain coming from internet to my internal web server except for one domain (this.example.com)
A sort of schema:
INTERNET->Apache Proxy->Internal Web server (default for any domain)
INTERNET->Apache Proxy->Differente Web Server (this.example.com)
What kind of configuration do i have to setup on this Apache Proxy? I read about Proxypass and similar string, but i didn't understand how to proxy "the default" to my internal web server...
Thank you for your help
This is working on "defaults", but domain this.example.com does not work...
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^(.*)$ http://192.168.1.2$1 [P]
</VirtualHost>
<VirtualHost *:80>
LogLevel warn
ServerName this.example.com
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>