问题,如题。怎么折腾都是一直访问第一个虚拟主机,后来找到问题所在。是我配置的不对。错误配置是这样的:问题出在了: ProxyPass / http://192.168.13.111/
要改成这样: ProxyPass / http://www.test.com/
所以正确的配置是这样的:
另外需要注意的是,需要在/etc/hosts 中加一条记录
192.168.13.111 www.test.com
- ServerName www.test.com
- CustomLog "/dev/null" combined
- ProxyRequests Off
- Order deny,allow
- Allow from all
- ProxyPass / http://192.168.13.111/
- ProxyPassReverse / 192.168.13.111/
要改成这样: ProxyPass / http://www.test.com/
所以正确的配置是这样的:
- ServerName www.test.com
- CustomLog "/dev/null" combined
- ProxyRequests Off
- Order deny,allow
- Allow from all
- ProxyPass / http://www.test.com/
- ProxyPassReverse / 192.168.13.111/
另外需要注意的是,需要在/etc/hosts 中加一条记录
192.168.13.111 www.test.com
0
本帖最后由 starry 于 2016-2-1 17:30 编辑
我按您的方法时
出现如下警告
# apachectl -t
[Mon Feb 01 17:15:38 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
Syntax OK
# apachectl graceful
[Mon Feb 01 17:16:12 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
访问的web是proxy服务器上的默认虚拟主机
查看错误日志
把改为时,没有报错
# apachectl -t
Syntax OK
# apachectl restart
但是访问结果是500
Internal Server ErrorThe server encountered an internal error ormisconfiguration and was unable to completeyour request.
Please contact the server administrator, you@example.com and inform them of the time the error occurred,and anything you might have done that may havecaused the error.
More information about this error may be availablein the server error log.
查看错误日志
[warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
查看httpd.conf文件,已经加载了该模块
LoadModule proxy_module modules/mod_proxy.so
我按您的方法时
- <VirtualHost *:80>
- ServerAdmin webmaster@dummy-host.example.com
- DocumentRoot "/usr/local/apache2/htdocs/"
- ServerName dummy-host.example.com
- ServerAlias www.dummy-host.example.com
- </VirtualHost>
- <VirtualHost *>
- ServerName www.discuz.com
- CustomLog "/dev/null" combined
- ProxyRequests Off
- <Proxy *>
- Order deny,allow
- Allow from all
- </Proxy>
- ProxyPass / http://www.discuz.com/
- ProxyPassReverse / 192.168.0.105/
- </VirtualHost>
# apachectl -t
[Mon Feb 01 17:15:38 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
Syntax OK
# apachectl graceful
[Mon Feb 01 17:16:12 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
访问的web是proxy服务器上的默认虚拟主机
查看错误日志
- [Mon Feb 01 17:27:33 2016] [notice] Graceful restart requested, doing restart
- [Mon Feb 01 17:27:33 2016] [warn] NameVirtualHost *:80 has no VirtualHosts
- [Mon Feb 01 17:27:33 2016] [notice] Apache/2.2.24 (Unix) PHP/5.4.44 configured -- resuming normal operations
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7094 for worker proxy:reverse
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7094 for worker http://www.discuz.com/
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7093 for worker proxy:reverse
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7093 for worker http://www.discuz.com/
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7095 for worker proxy:reverse
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7095 for worker http://www.discuz.com/
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7092 for worker proxy:reverse
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7092 for worker http://www.discuz.com/
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7091 for worker proxy:reverse
- [Mon Feb 01 17:27:33 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7091 for worker http://www.discuz.com/
- [Mon Feb 01 17:27:35 2016] [error] proxy: ap_get_scoreboard_lb(1) failed in child 7096 for worker proxy:reverse
- [Mon Feb 01 17:27:35 2016] [error] proxy: ap_get_scoreboard_lb(0) failed in child 7096 for worker http://www.discuz.com/
把
# apachectl -t
Syntax OK
# apachectl restart
但是访问结果是500
Internal Server ErrorThe server encountered an internal error ormisconfiguration and was unable to completeyour request.
Please contact the server administrator, you@example.com and inform them of the time the error occurred,and anything you might have done that may havecaused the error.
More information about this error may be availablein the server error log.
查看错误日志
[warn] proxy: No protocol handler was valid for the URL /. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
查看httpd.conf文件,已经加载了该模块
LoadModule proxy_module modules/mod_proxy.so
0
{:7_193:}
问题解决了,一开始我只安装了 mod_proxy.c prox_util.c 这两个模块,后来查了下 是下面几个也都要装,然后用的是
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy.c prox_util.c
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy_http.c
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy_connect.c
starry 发表于 2016-2-1 17:24
我按您的方法时
出现如下警告
# apachectl -t
{:7_193:}
问题解决了,一开始我只安装了 mod_proxy.c prox_util.c 这两个模块,后来查了下 是下面几个也都要装,然后用的是
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy.c prox_util.c
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy_http.c
#/usr/local/apache2/bin/apxs -i -c -a mod_proxy_connect.c
0
你在前面定义一个NameVirtualHost * 然后用应该也是可以的吧
starry 发表于 2016-2-1 17:43
问题解决了,一开始我只安装了 mod_proxy.c prox_util.c 这两个模块,后来查了下 是下面几个 ...
你在前面定义一个NameVirtualHost * 然后用
0
问一下,如果源文件里没有mod_proxy.c prox_util.c mod_proxy_http.c mod_proxy_connect.c这几个c文件,是不是只能重新编译了?
starry 发表于 2016-2-1 17:43
问题解决了,一开始我只安装了 mod_proxy.c prox_util.c 这两个模块,后来查了下 是下面几个 ...
问一下,如果源文件里没有mod_proxy.c prox_util.c mod_proxy_http.c mod_proxy_connect.c这几个c文件,是不是只能重新编译了?
编辑回复