Apache virtual proxy, do not redirect from root - apache

I have the following in my vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName ci.myserver.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
ProxyPassReverseCookiePath / /
</VirtualHost>
Now, when I visit my root (myserver.com) I get my Jenkins, as well as when I visit ci.myserver.com
How to I get not redirected to CI when I visit myserver.com, but only make it work for ci.myserver.com
Updated version
This resolved an issue.
<VirtualHost *:80>
ServerName ci.myserver.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
ProxyPassReverseCookiePath / /
</VirtualHost>
<VirtualHost *:80>
ServerName myserver.com
DocumentRoot /
<Directory />
Require all granted
</Directory>
</VirtualHost>

You need to create another VirtualHost, otherwise hostnames that resolve the ip of your server will hit the default VirtualHost, which in your case is ci.myserver.com.
Add another to the file:
<VirtualHost *:80>
ServerName myserver.com
DocumentRoot /path/to/root
<Directory /path/to/root>
Order allow,deny
allow from all
</Directory>
</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>

404 Error while Sync Server in SAAS

I am having problem while i sync the server and this type of error message is displayed.
i am using apache2 server
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName o9.local
ServerAlias *.o9.local
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
ProxyPass / http://127.0.0.1:8097/
ProxyPassReverse / http://127.0.0.1:8097/
ProxyPreserveHost On
ProxyErrorOverride Off
SetEnv proxy-nokeepalive 1
ErrorLog /var/log/apache2/webclient-error.log
CustomLog /var/log/apache2/webclient-access.log combined
</VirtualHost>
can you help me to find out the solution ?

running jenkins behind apache2 on subdomain and different port

I am attempting to get a jenkins instance (running on http://localhost:8080/) to be visible at http://ci.domain.com:80/.
Current status:
* Browsing to ci.domain.com gives me the content of domain.com
* Browsing to ci.domain.com:8080 shows jenkins
* Browsing to domain.com:8080 shows jenkins
Ideal status:
* Browsing to ci.domain.com shows jenkins
* Browsing to ci.domain.com:8080 redirects to ci.domain.com
* Browsing to domain.com:8080 does whatever the server would do if there were nothing running on port 8080
My current apache site config (working as expected for shifting traffic to HTTPS) is as follows:
<VirtualHost *:8080>
ServerName ci.domain.com
ServerAlias ci
Redirect temp / http://ci.domain.com/
</VirtualHost>
<VirtualHost *:80>
ServerName ci.domain.com
ServerAlias ci
ProxyRequests Off
ProxyPreserveHost On
AllowEncodedSlashes NoDecode
<Proxy http://localhost:8080/*>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://localhost:8080/ nocanon
ProxyPassReverse / http://localhost:8080/
</VirtualHost>
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com
Redirect permanent / https://domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/domain.com
<Directory /var/www/domain.com/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml $
</IfModule>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain.com/fullchain.pem
<FilesMatch "\.(cgi|shtml|phtml_php)$">
SSLOptions +StdEnvVars
</FilesMatch>
</VirtualHost>
Any help is appreciated.

tomcat proxy - How to set up a proxy location for some virtual host apache 2

ive my httpd.conf generic option as :
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
I would like to configure virtualhost which include
Like
<VirtualHost *:80>
ServerName www.localhost
ServerAlias locathost
DocumentRoot "C:\wamp\www\tomcat"
<Location />
ProxyPass http://localhost:8080/
ProxyPassReverse http://localhost:8080/
</Location>
<VirtualHost *:80>
in the same time if i called other virtaul host it should serv through port 80 not 8080
like
<VirtualHost *:80>
ServerName www.localhost2nd
ServerAlias locathost2nd
DocumentRoot "C:\wamp\www\phpapp"
<VirtualHost *:80>
so what do i miss in my configuration its never works

Apache - Proxy all subdomains from one IP

I'm trying to handle subdomains on a specific server and the normal URL from all servers. They're behind a load balancer. This works for http://test.com and it load balances.
For subdomains I can't tell if the proxy is working or why I'm getting a 404 error. Is there anything wrong with my config?
DNS: example.com 111.111.111.111
Load Balancer: 111.111.111.111
Master, write server: 222.222.222.222
httpd.conf, mirrored to all servers:
<Directory />
Header add myServerName "anglefish" # add a string for testing which server
Header add myServerTimes "D%D t%t"
</Directory>
000-default mirrored to each server except master
#Proxy subdomains from one server
<VirtualHost *:80>
ServerName *.example.com
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://222.222.222.222/
ProxyPassReverse / http://222.222.222.222/
</VirtualHost>
<VirtualHost *:443>
ServerName *.example.com
SSLEngine on
SSLProxyEngine On
SSLEngine on
SSLCertificateFile /etc/apache2/.ssh/example.com.crt
SSLCertificateKeyFile /etc/apache2/.ssh/example.com.key
SSLCertificateChainFile /etc/apache2/.ssh/example.com_bundle.crt
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://222.222.222.222/
ProxyPassReverse / http://222.222.222.222/
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/vhosts/example.com/public_html
<Directory /var/www/vhosts/example.com/public_html>
Options -Indexes FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerName example.com
ServerAlias example.com
DocumentRoot /var/www/vhosts/example.com/public_html
SSLEngine on
SSLCertificateFile /etc/apache2/.ssh/example.com.crt
SSLCertificateKeyFile /etc/apache2/.ssh/example.com.key
SSLCertificateChainFile /etc/apache2/.ssh/example.com_bundle.crt
</VirtualHost>