1

I'm trying to set up a reverse proxy for HeadshotBox on my web server under the directory https://example.com/csgo/, but I can't get it to serve subdirectories from the /csgo/ directory.

This is what I have in my configuration:

  ProxyPass /csgo http://localhost:4000/                                                                                                                                                      
  ProxyPassReverse /csgo http://localhost:4000/                                                                                                                                               
  ProxyHTMLURLMap http://localhost:4000 /csgo/                                                                                                                                                

  <Location /csgo>                                                                                                                                                                            
    ProxyPassReverse /                                                                                                                                                                        
    ProxyHTMLURLMap / /csgo/                                                                                                                                                                  
  </Location>     

I've tried all sorts of voodoo, but it still gives a 404 for resources under a subdirectory. For instance, the server running on localhost:4000 has an /api directory whence it gets information like the application version, but instead of sending the requests to https://example.com/csgo/api, it sends them to https://example.com/api.

I can get it to work if I proxy the /api directory to http://localhost:4000/api, like so:

  <Location /api>                                                                                                                                                                           
    ProxyPass http://localhost:4000/api                                                                                                                                                     
    ProxyPassReverse http://localhost:4000/api                                                                                                                                              
  </Location>                                                                                                         

But what I really want is to rewrite everything to be under https://example.com/csgo/, since I would like to have a separate service under https://example.com/api in the future. I can make a virtualhost for this server, but I want to reuse my site-wide SSL configuration and authentication, if possible.

I'm aware that questions like this pop up every day here, but I've been searching for a few hours and I can't find anything that works. Any help would be much appreciated.

Thank you for your time.

EDIT: As requested, here's my entire virtualhost configuration for the site:

<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>

And here's my access log:

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"                                                                                                                                                        
8
  • What do you want? https://example.com/csgo/ reverse proxied to http://localhost:4000/ and nothing more? Then you only need lines 1-3 (if you need ProxyHTMLURLMap at all), but with /csgo/ (trailing slash), you don't necessarily need a Location block.
    – Lenniey
    Jul 5, 2019 at 12:31
  • Sorry if I wasn't clear enough, I also want https://example.com/csgo/api reverse proxied to htp://localhost:4000/api, as well as any other request originating from the server to point to https://example.com/csgo/* instead of https://example.com/*.
    – Txema
    Jul 5, 2019 at 12:35
  • OK, then try the config. ProxyPass /csgo/ http://localhost:4000/ ProxyPassReverse /csgo/ http://localhost:4000/ should be enough.
    – Lenniey
    Jul 5, 2019 at 12:38
  • I tried with just those two options, when I load the page I get a few requests to https://example.com/api which result in a 404. Maybe it's a bug in the server code? All my other reverse proxy configurations work fine with these directives.
    – Txema
    Jul 5, 2019 at 12:42
  • Could you post your complete site config? What's the access log looking like? 404 for the "correct" path, or does it redirect to somewhere else?
    – Lenniey
    Jul 5, 2019 at 12:45

0

You must log in to answer this question.

Browse other questions tagged .