title: Proxy request through Apache host to docker container
body: <p>I have an Ubuntu server host running an Apache web server. Running on this host is a docker container serving Geoserver (via Tomcat) (built from this <a href="https://github.com/kartoza/docker-geoserver" rel="nofollow noreferrer">image</a>) with a port configuration as such: 0.0.0.0:32770->8080/tcp</p>
  
  <p>I can access Geoserver just fine using <a href="http://my.domain:32770/geoserver" rel="nofollow noreferrer">http://my.domain:32770/geoserver</a><br>
  I have a redirect configured in Apache on the host to serve all requests over HTTPS (see code snippet below), which does not play nicely with the port in requests like this(ie. <a href="https://my.domain:32770/geoserver" rel="nofollow noreferrer">https://my.domain:32770/geoserver</a>)  </p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
          # sending http requests to https
          ServerName data.nrri.umn.edu
          Redirect permanent / https://data.nrri.umn.edu/
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>My attempt at a workaround for this is to use the <code>ProxyPass</code> directive in an Apache config file:  </p>
  
  <pre><code>ProxyRequests Off
  ProxyPreserveHost On
  
  ProxyPass /my-geoserver http://127.0.0.1:32770/geoserver
  ProxyPassReverse /my-geoserver http://127.0.0.1:32770/geoserver
  </code></pre>
  
  <p>When I use the URL that I would expect would get me to the Geoserver home page like the one above does (ie. <a href="http://my.domain/my-geoserver" rel="nofollow noreferrer">http://my.domain/my-geoserver</a>) I am redirected to
  <a href="https://my.domain/geoserver/index.html" rel="nofollow noreferrer">https://my.domain/geoserver/index.html</a> and presented with 404 Not Found.<br>
  I should also note that both <a href="http://my.domain:32770/geoserver" rel="nofollow noreferrer">http://my.domain:32770/geoserver</a> and <a href="http://my.domain:32770/geoserver/index.html" rel="nofollow noreferrer">http://my.domain:32770/geoserver/index.html</a> resolve to <a href="http://my.domain:32770/geoserver/web/" rel="nofollow noreferrer">http://my.domain:32770/geoserver/web/</a></p>
  
  <p>What am I doing wrong here?</p>
  
  <p><em>Edit</em>
  Output from <code>curl -L -v -o /dev/null data.nrri.umn.edu/nra-geoserver</code></p>
  
  <pre><code>* 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)
  &gt; GET /nra-geoserver HTTP/1.1
  &gt; User-Agent: curl/7.35.0
  &gt; Host: data.nrri.umn.edu
  &gt; Accept: */*
  &gt;
  &lt; HTTP/1.1 302 Found
  &lt; Date: Fri, 19 May 2017 15:28:35 GMT
  * Server Apache-Coyote/1.1 is not blacklisted
  &lt; Server: Apache-Coyote/1.1
  &lt; Location: /geoserver/index.html
  &lt; Content-Length: 0
  &lt; Set-Cookie: JSESSIONID=DFECFFB91353A34C407488EAAF70A2B4; Path=/geoserver; HttpOnly
  &lt;
    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)
  &gt; GET /geoserver/index.html HTTP/1.1
  &gt; User-Agent: curl/7.35.0
  &gt; Host: data.nrri.umn.edu
  &gt; Accept: */*
  &gt;
  &lt; HTTP/1.1 301 Moved Permanently
  &lt; Date: Fri, 19 May 2017 15:28:35 GMT
  * Server Apache/2.4.7 (Ubuntu) is not blacklisted
  &lt; Server: Apache/2.4.7 (Ubuntu)
  &lt; Location: https://data.nrri.umn.edu/geoserver/index.html
  &lt; Content-Length: 336
  &lt; Content-Type: text/html; charset=iso-8859-1
  &lt;
  * 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.
  &gt; GET /geoserver/index.html HTTP/1.1
  &gt; User-Agent: curl/7.35.0
  &gt; Host: data.nrri.umn.edu
  &gt; Accept: */*
  &gt;
  &lt; HTTP/1.1 404 Not Found
  &lt; Date: Fri, 19 May 2017 15:28:35 GMT
  * Server Apache/2.4.7 (Ubuntu) is not blacklisted
  &lt; Server: Apache/2.4.7 (Ubuntu)
  &lt; Content-Length: 301
  &lt; Content-Type: text/html; charset=iso-8859-1
  &lt;
  { [data not shown]
  100   301  100   301    0     0   4404      0 --:--:-- --:--:-- --:--:--  4404
  * Connection #1 to host data.nrri.umn.edu left intact
  </code></pre>