编辑:最后,我解决了这个问题,并在下面发布了解决方案。
在本地主机端口4567上,我有一个由sinatra服务器提供的gollum wiki。我想让它从外部世界访问www.mysite.com/wiki
我在Ubuntu12.04上运行了Appach-2.2服务器,启用了mod_proxy和mod_proxy_http。
我的vhosts.conf包含:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/mysite
ServerName www.mysite.pl
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /wiki/ http://localhost:4567/
ProxyPassReverse /wiki/ http://localhost:4567/
ProxyHTMLURLMap http://localhost:4567 /wiki
<Location /wiki>
Order allow,deny
Allow from all
RequestHeader unset Accept-Encoding
SetOutputFilter proxy-html
ProxyPass http://localhost:4567
ProxyPassReverse /wiki
ProxyHTMLURLMap / /wiki/
ProxyHTMLURLMap /wiki /wiki
ProxyHTMLURLMap http://localhost:4567 /wiki
</Location>
<Directory / >
AllowOverride AuthConfig FileInfo Indexes Limit Options
Order allow,deny
allow from all
</Directory>
LogLevel debug
ScriptAlias /cgi-bin/ /var/www/mysite/cgi-bin/
<Directory /var/www/mysite/cgi-bin/>
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /srv/src.git
ServerName git.mysite.com
DAVLockDB /var/lock/apache2/davlockDB
<Directory /srv/src.git >
DAV On
Options Indexes MultiViews
IndexOptions FancyIndexing
Order allow,deny
Allow from all
AuthType Basic
AuthName "git repository"
AuthUserFile /etc/apache2/passwd
Require valid-user
</Directory>
</VirtualHost>Sinatra日志显示,当我获取www.mysite.com/wiki时,确实可以访问localhost:4567站点。但是apache返回一个错误。Apache日志显示:
[Sun Nov 09 02:04:01 2014] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //localhost:4567
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(1506): [client 93.105.202.224] proxy: http: found worker http://localhost:4567 for http://localhost:4567/
[Sun Nov 09 02:04:01 2014] [debug] mod_proxy.c(1020): Running scheme http handler (attempt 0)
[Sun Nov 09 02:04:01 2014] [debug] mod_proxy_http.c(1973): proxy: HTTP: serving URL http://localhost:4567/
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2011): proxy: HTTP: has acquired connection for (localhost)
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2067): proxy: connecting http://localhost:4567/ to localhost:4567
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2193): proxy: connected / to localhost:4567
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2444): proxy: HTTP: fam 2 socket created to connect to localhost
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2576): proxy: HTTP: connection complete to 127.0.0.1:4567 (localhost)
[Sun Nov 09 02:04:01 2014] [debug] mod_proxy_http.c(1743): proxy: start body send
[Sun Nov 09 02:04:01 2014] [debug] mod_proxy_http.c(1847): proxy: end body send
[Sun Nov 09 02:04:01 2014] [debug] proxy_util.c(2029): proxy: HTTP: has released connection for (localhost)
[Sun Nov 09 02:04:01 2014] [error] [client 93.105.202.224] File does not exist: /var/www/Home"Home“位置名由gollum-wiki (作为其默认主页)正确地返回,有人能解释我的这种行为吗?
答:它有助于将http://localhost:4567的每一次发生转变为http://localhost:4567/wiki。当我登录到我的http服务器并使用lynx访问127.0.0.1:4567时,我有了一个尝试它的想法。它想了几秒钟,然后返回127.0.0.1:4567/wiki/Home
发布于 2014-11-09 14:33:41
看上去:
解决方案是确保/wiki被添加到gollum页面中。以如下方式启动:
$ gollum --host 127.0.0.1 --port 4567 --base-path wikiPS。您也不需要在Apache配置中指定"ProxyHTMLURLMap“;ProxyPass和ProxyPassReverse就足够了。
https://serverfault.com/questions/643015
复制相似问题