我有一个服务器运行在本地主机:3030,我可以访问一些网页。 当我在localhost:3030/index.html上做一个wget时,我获得了网页。 使用ProxyPassMatch,我试图将example.com/sparql/<something>上的请求redirect到locahost:3030/<something>但它不起作用。 我使用的是debian,configuration如下:
<VirtualHost *:80> ServerName example.com ProxyPass "/sparql" "http://localhost:3030/" ProxyPassReverse "/sparql" "http://localhost:3030/" ProxyPassReverseCookieDomain "localhost" "example.com" .... <VirtualHost *:80>
当我通过example.com/sparql/index.html发送请求时,页面正在返回,但是没有任何图像和css文件正在返回。 configuration有问题吗?
为什么使用ProxyPassMatch这样一个简单的反向代理 ? 你可以…
<VirtualHost *:80> ServerName example.com ... ProxyPass "/sparql/" "http://localhost:3030/sparql/" ProxyPassReverse "/sparql/" "http://localhost:3030/sparql/" ProxyPassReverseCookieDomain "localhost" "example.com" </VirtualHost>
然后,如果你的内容在http://localhost:3030/那么可能会有一些硬编码的内容在HTML主体中引用/而不是/sparql/ 。 虽然也可以使用mod_substitute更改内容, 但这可能会导致其他问题。 因此,build议使用子域而不是附加部分到path中,如下所示:
<VirtualHost *:80> ServerName sparql.example.com ... ProxyPass "/" "http://localhost:3030/" ProxyPassReverse "/" "http://localhost:3030/" ProxyPassReverseCookieDomain "localhost" "sparql.example.com" </VirtualHost>