How to Configure Apache mod_proxy to proxy Glassfish 4.1 on Fedora 21?

Sombriks asked:

i have glassfish 4.1 running and checked the JK-Listener option on http-listener-2:

JK Listener checked

also i already installed apache (sudo yum install httpd) and created the following file on /etc/httpd/conf.d:

/etc/httpd/conf.d/ajp.conf

ProxyPass /painel ajp://localhost:8181/painel

ProxyPassReverse /painel ajp://localhost:8181/painel

But all that i got trying to use the ajp protocol was the 503 http error.

What i am missing?

if i change the protocol from ajp to http and port to 8080, it works. But the idea was to use the ajp.

Any help is welcome.

My answer:


You’ve likely run into an issue with SELinux.

By default the web server can only make outbound connections to a limited range of ports:

# semanage port -l | grep http
http_cache_port_t              tcp      8080, 8118, 8123, 10001-10010
http_cache_port_t              udp      3130
http_port_t                    tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t            tcp      5988
pegasus_https_port_t           tcp      5989

Port 8181 isn’t in that list.

So you have two options. You can either:

  1. Add your desired port to the allowed ports list:

    # semanage port -a -t http_port_t -p tcp 8181
    
  2. Run Glassfish on one of the existing allowed ports.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.