I have a little awkward setup with a Apache 2 webserver being the gatekeeper and proxying traffic based on the incoming domain:
<VirtualHost *:80>
ServerName example.org
RewriteEngine On
RewriteRule ^/(.*) http://localhost:3000/$1 [P]
</VirtualHost>
Running under localhost:3000
I have a lighttpd running which serves static content and acts as a reverse proxy for two other services, running on port 3001 and 3002. The configuration looks like this:
# lighttpd will also be used to forward requests to node.js
server.modules = (
"mod_proxy"
)
# This config is meant to work relative to certain directories,
# it is not meant to be used somewhere globally in /etc/
var.projectRoot = var.CWD
# Setting up paths
server.document-root = var.projectRoot + "/client"
# Port to listen on
server.port = 3000
# We don't want to provide names of individual files
index-file.names = ( "index.html" )
# Serve all API calls to the API server
$HTTP["url"] =~ "^/api/.*$" {
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 3001 )
)
)
}
# Serve all pages that are not known as static or api routes
# to the page instance
$HTTP["url"] !~ "^/(assets|game|ige|api).*$" {
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 3002 )
)
)
}
The whole setup works fine for the following cases:
GET /assets/textures/sources.txt
serves a static file from theclient
directory.GET /api/games/byId/123
retrives the correct data from the API server on port 3001GET /
retrieves the page from port 3002
However, the request GET /game
(where the game
folder has a index.html
file) does get served, but changes the URL to http://localhost:3000/game
. Or to be more precise: It changes to whatever URL I have specified in the Apache2 vhost, If I put example.org:3000
in there, it will attempt to serve example.org:3000/game
, Ignoring the [P] proxy directive.
Things only go wrong when lighttpds "rewrites" to deliver folder/index.html
files for folder/
requests. Can anybody tell me why?
The behaviour is the same for Chrome and Firefox and I don't get any HTTP redirects.