我正在尝试设置反向代理头像框在我的网络服务器上的目录下https://example.com/csgo/,但我无法让它为 /csgo/ 目录中的子目录提供服务。
这是我的配置中的内容:
ProxyPass /csgo http://localhost:4000/
ProxyPassReverse /csgo http://localhost:4000/
ProxyHTMLURLMap http://localhost:4000 /csgo/
<Location /csgo>
ProxyPassReverse /
ProxyHTMLURLMap / /csgo/
</Location>
我试过各种巫术,但子目录下的资源仍然会返回 404。例如,在 localhost:4000 上运行的服务器有一个 /api 目录,它从中获取应用程序版本等信息,但不会将请求发送到https://example.com/csgo/api,它会将它们发送到https://example.com/api。
如果我将 /api 目录代理到http://本地主机:4000/api,像这样:
<Location /api>
ProxyPass http://localhost:4000/api
ProxyPassReverse http://localhost:4000/api
</Location>
但我真正想要的是重写一切https://example.com/csgo/,因为我想在https://example.com/api将来。我可以为该服务器创建一个虚拟主机,但如果可能的话,我想重用我的站点范围的 SSL 配置和身份验证。
我知道这里每天都会出现这样的问题,但我已经搜索了几个小时,却找不到任何有用的方法。任何帮助都将不胜感激。
感谢您的时间。
编辑:根据要求,这是我的网站的整个虚拟主机配置:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
Alias /downloads /data/downloads
<Location /downloads>
Header set Content-Disposition inline
</Location>
Alias /phpsysinfo /usr/share/phpsysinfo
# Basic auth enabled site-wide
<Location />
Order allow,deny
Allow from all
AuthType Basic
AuthName "auth"
AuthBasicProvider dbd
Require valid-user
AuthDBDUserPWQuery "SELECT password FROM users WHERE name = %s"
</Location>
# ProxyRequests off
ProxyHTMLExtended on
ProxyPass /register http://localhost:5280/register
ProxyPassReverse /register http://localhost:5280/register
# Basic auth disabled for BOSH
<Location /http-bind>
Order allow,deny
Allow from all
Satisfy Any
</Location>
ProxyPass /http-bind http://localhost:5280/http-bind/
ProxyPassReverse /http-bind http://localhost:5280/http-bind/
ProxyPass /docker/ http://localhost:9000/
ProxyPassReverse /docker/ http://localhost:9000/
ProxyHTMLURLMap http://localhost:9000 /docker/
Redirect permanent /docker /docker/
<Location /docker>
ProxyPassReverse /
ProxyPassReverseCookiePath / /docker
SetOutputFilter INFLATE;proxy-html;DEFLATE
ProxyHTMLURLMap / /docker/
ProxyHTMLURLMap /docker/ /docker/
</Location>
ProxyPass /csgo/ http://localhost:4000/
ProxyPassReverse /csgo/ http://localhost:4000/
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
这是我的访问日志:
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/index.html HTTP/1.1" 304 376 "-" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.\
0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/angular/angular.min.js HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5\
.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/jquery/dist/jquery.min.js HTTP/1.1" 304 376 "https://example.com/csgo/index.html" "Mozill\
a/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js HTTP/1.1" 304 376 "https://example.com/csgo/in\
dex.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/angular-route/angular-route.min.js HTTP/1.1" 304 376 "https://example.com/csgo/index.html\
" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/js/app.js?v=0.15 HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux \
x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/js/controllers.js?v=0.15 HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora\
; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/js/themer.js?v=0.15 HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Lin\
ux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/highcharts-ng/dist/highcharts-ng.min.js HTTP/1.1" 304 223 "https://example.com/csgo/index\
.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/bignumber.js/bignumber.min.js HTTP/1.1" 304 376 "https://example.com/csgo/index.html" "Mo\
zilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/font-awesome-animation/dist/font-awesome-animation.min.css HTTP/1.1" 304 223 "https://www.ro\
tura.org/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/highcharts-release/highcharts.js HTTP/1.1" 304 376 "https://example.com/csgo/index.html" \
"Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/hsbox.css HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64;\
rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/bootstrap/dist/css/bootstrap-theme.min.css HTTP/1.1" 200 2239 "https://example.com/csgo/i\
ndex.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/bower_components/bootstrap/dist/css/bootstrap.min.css HTTP/1.1" 200 17713 "https://example.com/csgo/index.\
html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/hsbox-dark.css HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x8\
6_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/templates/player_list.html HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedo\
ra; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/templates/navbar.html HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; L\
inux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/img/bg.png HTTP/1.1" 304 223 "https://example.com/csgo/hsbox-dark.css" "Mozilla/5.0 (X11; Fedora; Linux x8\
6_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /api/folders HTTP/1.1" 404 599 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv\
:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /api/players?limit=50&offset=0 HTTP/1.1" 404 599 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora\
; Linux x86_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /csgo/img/hsbox.png HTTP/1.1" 304 223 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86\
_64; rv:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /api/config HTTP/1.1" 404 598 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:\
67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /api/version HTTP/1.1" 404 599 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv\
:67.0) Gecko/20100101 Firefox/67.0"
example.com:443 XXX.XXX.XXX.XXX - user [05/Jul/2019:13:25:19 +0200] "GET /api/authorized HTTP/1.1" 404 602 "https://example.com/csgo/index.html" "Mozilla/5.0 (X11; Fedora; Linux x86_64;\
rv:67.0) Gecko/20100101 Firefox/67.0"