通过Apache主机向Docker容器发送代理请求

我有一台运行Apache Web服务器的Ubuntu服务器主机。 在这个主机上运行的是一个Docker容器,它通过端口configuration来提供Geoserver(通过Tomcat)(从这个镜像构build):0.0.0.0:32770->8080/tcp

我可以使用http://my.domain:32770 / geoserver访问Geoserver
我在主机上的Apache中configuration了一个redirect,通过HTTPS提供所有的请求(请参阅下面的代码片段),在这样的请求中(如https://my.domain:32770 / geoserver )

<VirtualHost *:80> # sending http requests to https ServerName data.nrri.umn.edu Redirect permanent / https://data.nrri.umn.edu/ </VirtualHost> 

我尝试解决这个问题的方法是在Apacheconfiguration文件中使用ProxyPass指令:

 ProxyRequests Off ProxyPreserveHost On ProxyPass /my-geoserver http://127.0.0.1:32770/geoserver ProxyPassReverse /my-geoserver http://127.0.0.1:32770/geoserver 

当我使用URL,我期望会让我到像上面那样的Geoserver主页(即http://my.domain/my-geoserver ),我被redirect到https://my.domain/geoserver /index.html,并提供404 Not Found。
我还应该注意, http://my.domain:32770 / geoserver和http://my.domain:32770 / geoserver / index.html都会parsing为http://my.domain:32770 / geoserver / web /

我在这里做错了什么?

编辑 curl -L -v -o /dev/null data.nrri.umn.edu/nra-geoserver输出curl -L -v -o /dev/null data.nrri.umn.edu/nra-geoserver

 * Hostname was NOT found in DNS cache % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 131.212.123.7... * Connected to data.nrri.umn.edu (131.212.123.7) port 80 (#0) > GET /nra-geoserver HTTP/1.1 > User-Agent: curl/7.35.0 > Host: data.nrri.umn.edu > Accept: */* > < HTTP/1.1 302 Found < Date: Fri, 19 May 2017 15:28:35 GMT * Server Apache-Coyote/1.1 is not blacklisted < Server: Apache-Coyote/1.1 < Location: /geoserver/index.html < Content-Length: 0 < Set-Cookie: JSESSIONID=DFECFFB91353A34C407488EAAF70A2B4; Path=/geoserver; HttpOnly < 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 * Connection #0 to host data.nrri.umn.edu left intact * Issue another request to this URL: 'HTTP://data.nrri.umn.edu/geoserver/index.html' * Found bundle for host data.nrri.umn.edu: 0x95b8c0 * Re-using existing connection! (#0) with host data.nrri.umn.edu * Connected to data.nrri.umn.edu (131.212.123.7) port 80 (#0) > GET /geoserver/index.html HTTP/1.1 > User-Agent: curl/7.35.0 > Host: data.nrri.umn.edu > Accept: */* > < HTTP/1.1 301 Moved Permanently < Date: Fri, 19 May 2017 15:28:35 GMT * Server Apache/2.4.7 (Ubuntu) is not blacklisted < Server: Apache/2.4.7 (Ubuntu) < Location: https://data.nrri.umn.edu/geoserver/index.html < Content-Length: 336 < Content-Type: text/html; charset=iso-8859-1 < * Ignoring the response-body { [data not shown] 100 336 100 336 0 0 38536 0 --:--:-- --:--:-- --:--:-- 38536 * Connection #0 to host data.nrri.umn.edu left intact * Issue another request to this URL: 'https://data.nrri.umn.edu/geoserver/index.html' * Found bundle for host data.nrri.umn.edu: 0x95b8c0 * Hostname was NOT found in DNS cache * Trying 131.212.123.7... * Connected to data.nrri.umn.edu (131.212.123.7) port 443 (#1) * successfully set certificate verify locations: * CAfile: none CApath: /etc/ssl/certs * SSLv3, TLS handshake, Client hello (1): } [data not shown] * SSLv3, TLS handshake, Server hello (2): { [data not shown] * SSLv3, TLS handshake, CERT (11): { [data not shown] * SSLv3, TLS handshake, Server key exchange (12): { [data not shown] * SSLv3, TLS handshake, Server finished (14): { [data not shown] * SSLv3, TLS handshake, Client key exchange (16): } [data not shown] * SSLv3, TLS change cipher, Client hello (1): } [data not shown] * SSLv3, TLS handshake, Finished (20): } [data not shown] * SSLv3, TLS change cipher, Client hello (1): { [data not shown] * SSLv3, TLS handshake, Finished (20): { [data not shown] * SSL connection using ECDHE-RSA-AES256-GCM-SHA384 * Server certificate: * subject: C=US; ST=MN; L=Minneapolis; O=University of Minnesota; OU=Natural Resources Research Institute; CN=data.nrri.umn.edu * start date: 2017-04-18 00:00:00 GMT * expire date: 2020-04-17 23:59:59 GMT * subjectAltName: data.nrri.umn.edu matched * issuer: C=US; ST=MI; L=Ann Arbor; O=Internet2; OU=InCommon; CN=InCommon RSA Server CA * SSL certificate verify ok. > GET /geoserver/index.html HTTP/1.1 > User-Agent: curl/7.35.0 > Host: data.nrri.umn.edu > Accept: */* > < HTTP/1.1 404 Not Found < Date: Fri, 19 May 2017 15:28:35 GMT * Server Apache/2.4.7 (Ubuntu) is not blacklisted < Server: Apache/2.4.7 (Ubuntu) < Content-Length: 301 < Content-Type: text/html; charset=iso-8859-1 < { [data not shown] 100 301 100 301 0 0 4404 0 --:--:-- --:--:-- --:--:-- 4404 * Connection #1 to host data.nrri.umn.edu left intact 

好的,所以有两个redirect发生。 我不确定解决第一个问题的好方法(解决scheme和第二个解决scheme是可能的)。 但是,第二个,你应该能够添加尾随/到path。 由此产生的代理指令将是:

 ProxyPass /my-geoserver/ http://127.0.0.1:32770/geoserver/ ProxyPassReverse /my-geoserver/ http://127.0.0.1:32770/geoserver/ 

首先在http://data.nrri.umn.edu/geoserver/index.html尝试这个尝试,然后用http://data.nrri.umn.edu/nra-geoserver尝试下一步失败&#x3002; 如果前者工作但后者失败,我们可能还需要编辑一些Tomcatconfiguration(以启用远程IP阀https://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/ catalina / valves / RemoteIpValve.html )。