-
Notifications
You must be signed in to change notification settings - Fork 102
Klaus behind a reverse proxy
If you have a reverse proxy in front of the actual klaus instance, the easiest way to set it up is to use the WSGI application obtained by the make_app
function (see Quickstart).
If the proxy functions as a SSL/TLS termination proxy (i.e. HTTPS is provided between the browser and reverse proxy but HTTP is used between the reverse proxy and klaus), you'll have to add the X-Scheme header.
This assumes you want to mount klaus at http://code.publichost.com/code/
. If you don't use a prefix, you can omit the X-Script-Name
header.
<Location /code>
ProxyPass http://localhost:1337
ProxyPassReverse http://code.publichost.com/
RequestHeader set X-Script-Name /code
</Location>
For the TLS/SSL termination proxy setup, add the X-Scheme header:
<Location /code>
…
RequestHeader set X-Scheme https
</Location>
This assumes you want to mount klaus at http://code.publichost.com/code/
. If you don't use a prefix, you can omit the X-Script-Name
header.
location ^~ /code/ {
proxy_pass http://localhost:8080/;
proxy_pass_request_headers on;
proxy_set_header Host code.publichost.com;
proxy_set_header X-Script-Name /code;
}
Reference: uWSGI documentation
This assumes you want to mount klaus under the /code
prefix.
location /code/ {
include uwsgi_params;
uwsgi_pass unix:/path/to/uwsgi.sock;
}
Use uwsgi ... --manage-script-name --mount /code=/path/to/klaus.wsgi
or add the mount
and manage-script-name
options to your uWSGI configuration file.
If you want to use klaus at the root of your web server, you can simply run uwsgi ... --wsgi-file /path/to/klaus.wsgi
.
This assumes you want to mount klaus under the /code/
prefix, and use HTTPS.
handle_path /code/* {
reverse_proxy localhost:8080 {
header_up X-Script-Name /code
header_up X-Forwarded-Proto https
}
}