编辑 :最后我解决了这个问题,并发布了下面的解决scheme。
我有一个由本地主机端口4567上的sinatra服务器提供的gollum wiki。我想让它可以从外部访问www.mysite.com/wiki
我已经启动了mod_proxy和mod_proxy_http,在Ubuntu 12.04上运行appache-2.2服务器。
我的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
gollum-wiki(作为默认主页面)正确地返回了“Home”位置名称任何人都可以解释我的这种行为吗?
回答 :它有助于将http://localhost:4567
每一处出现改为http://localhost:4567/wiki
。 我有一个想法,当我login到我的http服务器,并使用lynx
访问127.0.0.1:4567
时尝试它。 它想了几秒钟,然后返回127.0.0.1:4567/wiki/Home
看起来像:
解决scheme是确保/wiki
被预先添加到gollum页面。 像这样启动它:
$ gollum --host 127.0.0.1 --port 4567 --base-path wiki
PS。 您也不需要在Apacheconfiguration中指定“ProxyHTMLURLMap”; ProxyPass和ProxyPassReverse就足够了。