Apache2 Virtual Host 503 error - apache2

Here is my apache2 virtual host config -
<VirtualHost *:80>
ServerName A.B.com
ProxyPreserveHost Off
ProxyPass / http://<ServerIP>:<appPort>/<app>/ timeout=3600 Keepalive=On
ProxyPassReverse / http://<ServerIP>:<appPort>/<app>/
ProxyTimeout 3600
</VirtualHost>
<Location "/">
Order allow,deny
Allow from all
</Location>
I have a route 53 entry for A.B.com pointing to this machine (the one with apache2)
I have ran a2ensite.. I am getting a 503 service unavailable on hitting A.B.com
However, A.B.com:appPort/app is working..
This definitely means I am missing something in apache2 configuration.. Can anyone point me out?

ProxyPreserveHost Off
should be on, and not need to mention http://, but in route you can mention http://.
further please check and paste error logs.

Related

Running grafana behind apache2 reverse proxy

I need to run grafana and kibana on a same server while running behind Apache2 reverse proxy
I manage to succeed with kibana, but grafana cause me some problems; in fact I don't how how to run the sub path.
I want these two services to run like this : X.X.X.X/kibana and X.X.X.X/grafana.
Here is my apache2 config and my grafana settings:
<VirtualHost *:80>
ServerName http://myipadress/kibana
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://myipadress:5601/
ProxyPassReverse / http://myipadress:5601/
</VirtualHost>
#--------------GRAFANA----------------------------
<VirtualHost *:80>
ServerName http://myipadress/grafana
ProxyRequests On
ProxyPreserveHost On
ProxyPass / http://myipadress:3000/
ProxyPassReverse / http://myipadress:3000/
</VirtualHost>
For grafana :
protocol = http
http_port = 3000
domain = myipadress
root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana
serve_from_sub_path = true
Does anyone know what I did wrong
Cheers
Hello after loosing too much time on it, I decided to change my reverse proxy and use NGINX.
I fact, there is a example of configuration in grafana's documentation, and I just added these lines
location /kibana {
proxy_pass http://localhost:5601/kibana;
}
And it just work for me

Obtain part of url in proxy balancer from one balancer member

I have cluster setup of Apache server . Behind this I have 2 Jboss instances which is load balanced by apache.
The configuration look somewhat like the below
<VirtualHost *:1111>
ServerAdmin admin#example.com
ServerName www.example.com
DocumentRoot "/apps"
ErrorLog "logs/https.www.example.com.-error_log"
TransferLog "logs/https.www.example.com-access_log"
LogLevel warn
<Directory "/apps">
Options -Indexes +FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
SSLProxyEngine On
SSLProxyVerify On
SSLProxyMachineCertificateFile "/apps/apache/conf/ssl/int/proxy.pem"
SSLProxyCACertificateFile "/apps/apache/conf/ssl/int/cert.pem"
RewriteEngine On
Header set Cache-Control "max-age=60, public"
<Proxy balancer://2node-aa>
BalancerMember https://app01:8089 route=node1
BalancerMember https://app02:8089 route=node2
ProxyPreserveHost On
ProxyPass /aa balancer://2node/aa stickysession=JSESSIONID|jsessionid
ProxyPass /static balancer://2node/static stickysession=JSESSIONID|jsessionid
ProxyPassReverse /aa balancer://2node/aa
ProxyPassReverse /static balancer://2node/static
ProxyPass /1/aa https://app01:8089/aa
ProxyPass /2/aa https://app02:8089/aa
ProxyPassReverse /1/aa https://app01:8089/aa
ProxyPassReverse /2/aa https://app02:8089/aa
ProxyPass /bb balancer://2node/rest stickysession=JSESSIONID|jsessionid
ProxyPassReverse /bb balancer://2node/bb
</VirtualHost>
In the url access certain part of the url i want it to be routed from second node i.e node2 of jboss.
e.g. if i am accessing http://www.example.com/aa/login/login.jsp i need this request to be process by node2 app02 only.
Rest of the request should load balance as normal access.
How do i set the apache to do it ?
I have tried lot of rewrite,<Location> and ProxyPassMatch none has worked so far.
Please Help. Thanks in advance.
I used the below statement in the configuration file which resolved the issue.
<Proxy balancer://2node-aa>
BalancerMember https://app02:8080 route=node2
</Proxy>
RewriteRule ^/aa/login/(.*)$ balancer://2node-aa%{REQUEST_URI} [P,QSA,L]
This link help me.
apache httpd mod_proxy load balancing with multiple virtual hosts url redirection
-Thanks

Gitlab6.0 and Apache2

please how to set Github 6.0 with Apache2?
Gitlab is installed according to the original instructions
Adjustment in Unicorn.rb
...
#listen "/home/git/gitlab/tmp/sockets/gitlab.socket", :backlog => 64
#listen "127.0.0.1:8080", :tcp_nopush => true
listen "127.0.0.1:8080"
...
My Apache2 conf is :
<VirtualHost *:80>
ServerName git.domain.com
ErrorLog /var/log/apache2/gitlab_error.log
CustomLog /var/log/apache2/gitlab_access.log combined
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
<Location />
ProxyPassReverse /
Order deny,allow
Allow from all
</Location>
</VirtualHost>
Bud i get :
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /users/sign_in.
Reason: Error reading from remote server
Thank you
In case this helps anyone else;
I had this same problem, but it was a lack of disk space in my case. I deleted some large backups and restarted apache with service httpd restart and my gitlab came back.

Reverse proxy with websocket mod_proxy_wstunnel

I have a problem with the web sockets and my reverse proxy Apache, I have upgraded in latest release 2.4.5 and loaded the module mod_proxy_wstunnel.
The httpd.conf :
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.toto.fr
ServerAlias toto.fr
ProxyPass /my_app http://1X.X.X.1:8080/my_app
ProxyPassReverse /web_pmr http://1X.X.X.1:8080/my_app
ProxyPassReverseCookiePath /my_app /
ProxyPassReverseCookieDomain localhost my_app
ProxyRequests off
ProxyTimeout 15
#WEBSOCKETS
ProxyPass /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/my_app/BasicWebsocketServlet retry=0
ProxyPassReverse /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/web_pmr/BasicWebsocketServlet retry=0
ErrorLog "logs/my_app_error.log"
LogLevel debug
CustomLog "logs/my_app_access.log" combined
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
When I test in my local URL, websockets are working but with the reverse proxy Apache, there is no trace in Tomcat logs.
This line:
ProxyPass /my_app/BasicWebsocketServlet ws://1X.X.X.1:8080/my_app/BasicWebsocketServlet retry=0
needs to come before this one:
ProxyPass /my_app http://1X.X.X.1:8080/my_app
Explanation (from https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxypass):
Ordering ProxyPass Directives
The configured ProxyPass and ProxyPassMatch rules are checked in the order of configuration. The first rule that matches wins. So usually you should sort conflicting ProxyPass rules starting with the longest URLs first. Otherwise later rules for longer URLS will be hidden by any earlier rule which uses a leading substring of the URL. Note that there is some relation with worker sharing. In contrast, only one ProxyPass directive can be placed in a Location block, and the most specific location will take precedence.
For the same reasons exclusions must come before the general ProxyPass directives.

How Can I Proxy To Multiple Application Running in Tomcat via mod_proxy

I have 2 web applications running under Tomcat6. Currently, I can access one of them via mod_proxy with the following config...
<VirtualHost xxx.xxx.xxx.xxx:80>
ServerAdmin email#email.com
ServerName staging.domain.com
ProxyPass /app1 http://localhost:8080/app1
ProxyPassReverse /app1 http://localhost:8080/app1
</VirtualHost>
Now, I can access app1 via http://staging.domain.com/app1. I also want to be able to access app2 the same way: http://staging.domain.com/app2. I configured a second VirtualHost however, only the first one works. Is this even possible, to proxy 2 web apps under a single domain? If so, any hints, tips, tricks would be greatly appreciated.
Ah, you're already pretty much doing it: just add extra ProxyPass/ProxyPassReverse statements.
<VirtualHost xxx.xxx.xxx.xxx:80>
ServerAdmin email#email.com
ServerName staging.domain.com
ProxyPass /app1 http://localhost:8080/app1
ProxyPassReverse /app1 http://localhost:8080/app1
ProxyPass /app2 http://localhost:8080/app2
ProxyPassReverse /app2 http://localhost:8080/app2
ProxyPass /app3 http://localhost:8080/app3
ProxyPassReverse /app3 http://localhost:8080/app3
</VirtualHost>

Resources