Author |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Wed 29 May '13 16:25 Post subject: Apache Port Forwarding to jboss - httpd.conf file help |
|
|
I am having an issue trying to get apache forwarding to work, I have just recently installed it on my CentOS VM and just playing around with it to get some understanding into apache.
When I got to http://localhost:8080/example2/ I get my webpage to be displayed however when I do this http://localhost/example2/ I get the following:
Quote: |
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.2.15 (CentOS) Server at localhost Port 80
|
I cannot figure out what has gone wrong, my httpd.conf file is below (i haven't included everything but its the bits which i've changed):
Code: |
ProxyRequests On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost> |
I start apache using:
/usr/sbin/apachectl -f /etc/httpd/conf/httpd.conf[code]
and then visit the page localhost/example2 which gives me the error as described above. Hoping someone may able to tell me what I could be doing wrong. Is there some additional setting that needs to be applied?
Also I have changed the httpd.conf to this:
[code]
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
[/code]
without the forward slash after port 8080 and get the error below:
Quote: |
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /example2.
Reason: DNS lookup failure for: localhost:8080example2
Apache/2.2.15 (CentOS) Server at localhost Port 80 |
Thanks |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Wed 29 May '13 16:50 Post subject: |
|
|
Just to note i've also tried this, which did not work:
Code: |
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 127.0.0.1
ProxyPass /example2 http://localhost:8080/example2
ProxyPassReverse /example2 http://localhost/example2
</VirtualHost>
|
|
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7404 Location: EU, Germany, Next to Hamburg
|
Posted: Wed 29 May '13 18:19 Post subject: |
|
|
Since the DNS lookup fails, you may use 127.0.0.1 instead of localhost or edit your /etc/hosts file |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Wed 29 May '13 18:39 Post subject: |
|
|
Thanks James for responding:
I changed it to this as you suggested but it did not make any difference I still get the same error
Code: |
<VirtualHost *:80>
ServerName 127.0.0.1
ProxyPass /example2 http://127.0.0.1:8080/example2
ProxyPassReverse /example2 http://127.0.0.1/example2
</VirtualHost>
|
http://127.0.0.1/ or localhost takes me to the Apache Test Page
http://127.0.0.1:8080/ and localhost:8080 takes me to the JBoss Enterprise Application Platform Page.
So they are both running but the redirect seems to be failing as cannot figure out why I get "Service Temporarily Unavailable" as settings look ok. |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Wed 29 May '13 18:57 Post subject: |
|
|
Also guessing the DNS Issue was due to this:
Quote: |
Reason: DNS lookup failure for: localhost:8080example2
|
The URL is concatenated should be localhost:8080/example2 or the way I want it localhost/example2
I get this error due to leaving out the forward slashes after the port as shown below (I weren't sure if I need them, but without them i get the DNS error and with them I get the original error which is to do with Service Unavailable):
|
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7404 Location: EU, Germany, Next to Hamburg
|
Posted: Wed 29 May '13 20:22 Post subject: |
|
|
You may try, if you haven't
Code: |
ProxyPass /example2/ http://127.0.0.1/example2/
ProxyPassReverse /example2/ http://127.0.0.1/example2/
|
However a "Service Unavailable" (503 error) means simple that apache can't connect to that url. Can you open on the server on which apache is running on http://127.0.0.1/example2/ in the browser? |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Wed 29 May '13 21:06 Post subject: |
|
|
James, I changed the ProxyPass as you suggested and now have the following:
Code: | <VirtualHost *:80>
ServerName 127.0.0.1
ProxyPass /example2/ http://127.0.0.1/example2/
ProxyPassReverse /example2/ http://127.0.0.1/example2/
</VirtualHost> |
Now going to the browser to:
http://127.0.0.1/example2/ I get: a 502 Error
Quote: | Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /example2/.
Reason: Error reading from remote server
Apache/2.2.15 (CentOS) Server at 127.0.0.1 Port 80 |
I can open this page in the browser: 127.0.0.1 and it gives me the test page for Apache stating:
Quote: | "This page is used to test the proper operation of the Apache HTTP server after it has been installed. If you can read this page it means that the Apache HTTP server installed at this site is working properly." |
|
|
Back to top |
|
Qmpeltaty
Joined: 06 Feb 2008 Posts: 182 Location: Poland
|
Posted: Thu 30 May '13 13:24 Post subject: |
|
|
It looks like your Apache can't connect to your proxy. 503 is error code for such issue. |
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7404 Location: EU, Germany, Next to Hamburg
|
Posted: Thu 30 May '13 14:19 Post subject: |
|
|
I was a bit of of order last night...
it should be
Code: |
ProxyPass /example2/ http://127.0.0.1:8080/example2/
ProxyPassReverse /example2/ http://127.0.0.1:8080/example2/
|
And the url should have been http://127.0.0.1:8080/example2/
Dunno why I forgot the :8080  |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7404 Location: EU, Germany, Next to Hamburg
|
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Thu 30 May '13 18:17 Post subject: |
|
|
James
I copied what you did on your jenkins server and tried with and without the example2/ in the URL but it made no differece it outputted an error in the apache error_log which i have wrapped in quote tags below:
Code: | <VirtualHost *:80>
ServerName 127.0.0.1
<Location />
ProxyPass ajp://localhost:8080/example2/
ProxyPassReverse ajp://localhost:8080/example2/
</Location>
</VirtualHost> |
Quote: | [Thu May 30 17:05:57 2013] [notice] Apache/2.2.15 (Unix) DAV/2 mod_jk/1.2.37 configured -- resuming normal operations
[Thu May 30 17:07:13 2013] [error] (70014)End of file found: ajp_ilink_receive() can't receive header
[Thu May 30 17:07:13 2013] [error] ajp_read_header: ajp_ilink_receive failed
[Thu May 30 17:07:13 2013] [error] (120006)APR does not understand this error code: proxy: read response failed from (null) (localhost) |
I have got mod_proxy and mod_proxy_ajp installed as show below:
Quote: | [root@localhost modules]# ls *mod_proxy*
mod_proxy_ajp.so mod_proxy_connect.so mod_proxy_http.so mod_proxy.so
mod_proxy_balancer.so mod_proxy_ftp.so mod_proxy_scgi.so |
|
|
Back to top |
|
James Blond Moderator

Joined: 19 Jan 2006 Posts: 7404 Location: EU, Germany, Next to Hamburg
|
Posted: Thu 30 May '13 21:19 Post subject: |
|
|
Your apache can't connect to the jboss neither over port 8080 nor ajp port. Firewall blocking? jboss is not listening on the local ip? |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Fri 31 May '13 0:17 Post subject: |
|
|
Don't have a firewall on the VM that I have deployed.
The webapp is deployed on jboss and can see the app deployed on 127.0.0.1:8080/example2 so assuming it is listening on this ip address.
As you suggest it must be appache that can't connect to jboss, might be a setting that is not configured in jboss. I'm using jboss 6 which is a little different to 5, and a lot of examples are available online that have used jboss 5 in particular the link I gave above which had an example of what needs to be done with the server.xml file, there must be something I need to do to the standalone.xml that is used in jboss 6 and 7 that needs configuring.
I've tried using ajp and http in the httpd.conf file and both give the 503 error, cannot figure out what needs to be done to resolve this issue  |
|
Back to top |
|
darkcloudi
Joined: 29 May 2013 Posts: 9 Location: England
|
Posted: Fri 31 May '13 19:15 Post subject: |
|
|
James, Many Many Thanks for your help.
I finally got it sorted, it was something missing in my standalone.xml file, the line where I specified connector name="ajp13" you can call this whatever you like I had to make sure this mapped up to the workers.properties file:
Quote: | <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="ajp13" protocol="AJP/1.3" socket-binding="ajp" scheme="http"/> |
Also required this line in standalone.xml:
Quote: | <system-properties>
<property name="jvmRoute" value="node1"/>
</system-properties> |
workers.properties file detailed below:
Code: | # Define list of workers that will be used
# for mapping requests
# The configuration directives are valid
# for the mod_jk version 1.2.37 and later
#
worker.list=loadbalancer,status
# Define Node1
# modify the host as your host IP or DNS name.
worker.node1.port=8009
worker.node1.host=localhost
worker.node1.type=ajp13
worker.node1.lbfactor=1
# worker.node1.connection_pool_size=10 (1)
# Load-balancing behaviour
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=node1
# Status worker for managing load balancer
worker.status.type=status |
I left the httpd.conf as this:
Code: | ProxyPass /example2/ ajp://localhost:8009/example2/
ProxyPassReverse /example2/ ajp://localhost:8009/example2/ |
The port reflected the port number specified in standalone.xml file for ajp.
Code: | <socket-binding name="ajp" port="8009"/> |
Now going to localhost/example2 my page is displayed. |
|
Back to top |
|