Use a Reverse Proxy for HTTPS Support¶
CodeScene doesn’t implement HTTPS support itself. Instead we recommend that you put a reverse proxy in front of the application if you need encryption. We recommend Nginx as the reverse proxy. The Nginx website provides documentation on configuring Nginx for HTTPS.
Here is a brief example of an Nginx proxy configuration:
http {
server {
listen 80;
server_name codescene.example.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name codescene.example.com;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
location / {
proxy_pass http://localhost:3003;
proxy_redirect http:// $scheme://;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
The proxy_redirect used above will rewrite all HTTP redirects from upstream to the current scheme, ie HTTPS. The browser will then receive the correct scheme directly, avoiding unnecessary round-trips.
There is also a Docker-based sample project that provides CodeScene wrapped by an Nginx reverse proxy with a self-signed certificate. It composes a CodeScene container and an Nginx container using a small docker-compose.yml file.