简体   繁体   中英

Setup mod_proxy on apache http server

I wanted to reverse proxy a web service from my tomcat server using apache web server. I have modified the httpd.conf

LoadModule proxy_module modules/mod_proxy.so

<Directory />
    AllowOverride none
    Require all denied
</Directory>

ProxyPass         /ROOT  http://localhost:8080/ROOT
ProxyPassReverse  /ROOT  http://localhost:8080/ROOT

My Tomcat server runs on port 8080, now when I run localhost/ROOT, I get error 500 internal server error.

This last entry in the error_log is:

[Thu Jul 04 14:17:00.097359 2013] [proxy:warn] [pid 18980:tid 4476780544] [client 127.0.0.1:50525] AH01144: No protocol handler was valid for the URL /ROOT. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
The last entry in the access_log is:
\n 127.0.0.1 - - [04/Jul/2013:14:17:00 -0400] "GET /ROOT HTTP/1.1" 500 528 \n

Any idea on what I am doing wrong here?

So it took some time but I figured out the way to do it. There is one more module which needs to be loaded. This is what the httpd.conf looks like

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

<Directory />
    AllowOverride none
    Require all denied
</Directory>

ProxyPass         /ROOT  http://localhost:8080/ROOT
ProxyPassReverse  /ROOT  http://localhost:8080/ROOT

This works for sure. :)

Since it's easy to overlook, pay attention to @muka's comment:

sudo a2enmod proxy  
sudo a2enmod proxy_http  
sudo service apache2 restart

Make sure to enable both modules proxy and proxy_http !

除了其他正确答案之外,如果您要代理https端点,则需要启用mod_ssl并将SSLProxyEngine on添加到您的vhost

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM