简体   繁体   中英

Apache virtualhost and reverse proxy not working in unprivileged port

I have an apache 2.2.15 webserver running in a RedHat 6.4 host for which I have limited privileges.

I have an httpd instance running in a directory owned by me. This instance has its own etc, logs, htdocs, conf ,etcetera and symbolic links to the main Apache bin and modules.

The DNS guy has arranged myinstance.example.com to point to the server's ip address.

I also have configured VirtualHosts in my httpd.conf because in the future I might need more than one instance running in this server.

The Listen directive in my VirtualHost's htttpd.conf is set to port 8081, so if I go to myinstance.example.com:8081 the index.html in VirtualHost's htdocs is displayed in my browser.

What I'd like to do now, is to "remove" the port number from the url and have myinstance.example.com to resolve to the VirtualHost in 8081.

I added the following block at the end of the VirtualHost's httpd.conf

<VirtualHost *:8081>
    ServerAdmin me@myemailaddress.com
    DocumentRoot /apps/LAMP/dev/appname/hostname/htdocs
    ServerName myinstance.example.com
    ProxyPreserveHost On
    ProxyPass / myinstance.example.com:8081/
    ProxyPassReverse / http://myinstance.example.com:8081/
    ErrorLog logs/error.log
    CustomLog logs/access.log common
</VirtualHost>

and in the same file, these lines are present too:

LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
.
.
.
ProxyRequests Off
ProxyVia On
ProxyPreserveHost On

I start my Apache instance using:

/usr/sbin/httpd -d /apps/LAMP/dev/appname/hostname -DPHP5 -f /apps/LAMP/dev/appname/hostname/etc/httpd.conf

When I point in my firefox browser to myinstance.example.org (without port number) I get "Unable to connect error" and the latest entries in error.log don't seem to be related to the issue.

[Tue Oct 07 13:59:28 2014] [error] (2)No such file or directory: mod_mime_magic: can't read magic file /apps/LAMP/dev/appname/hostname/conf/magic
[Tue Oct 07 13:59:28 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Tue Oct 07 13:59:28 2014] [error] (2)No such file or directory: mod_mime_magic: can't read magic file /apps/LAMP/dev/appname/hostname/conf/magic
[Tue Oct 07 13:59:28 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Oct 07 13:59:28 2014] [notice] Digest: done
[Tue Oct 07 13:59:28 2014] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
[Tue Oct 07 13:59:51 2014] [error] server reached MaxClients setting, consider raising the MaxClients setting

Any idea on what I may be doing wrong? Any suggestion?

First of all I would get rid of all the errors. The one that caught my attention and it might be a show stopper is this one:

[error] server reached MaxClients setting

consider raising the MaxClients setting

It got fixed by using the main Apache instance in port 80 acting as the reverse proxy.

I added this at the end of /etc/httpd/conf/httpd.conf

#Using host ip address
<VirtualHost 10.18.1.20:80>    
    ServerAdmin me@example.com
    #DocumentRoot /apps/LAMP/dev/appname/hostname/htdocs
    ServerName myinstance.example.com
    ProxyPreserveHost On
    ProxyPass / http://myinstance.example.com:8081/
    ProxyPassReverse / http://myinstance.example.com:8081/
    ErrorLog logs/error.log
    CustomLog logs/access.log common
</VirtualHost>

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