Skip to content
Asher edited this page May 11, 2023 · 2 revisions

1. Install NGINX

Debian-based:

sudo apt updatesudo apt install -y nginx certbot python3-certbot-nginx

CentOS:

sudo yum install nginx

2. Edit configuration

Update /etc/nginx/sites-available/code-marketplace using sudo with the following configuration:

server{listen80;listen [::]:80;server_name marketplace.example;location / {proxy_passhttp://localhost:3001/;proxy_set_header X-Forwarded-Host $http_host;proxy_set_header X-Forwarded-Proto $scheme;}}

3. Enable code-marketplace

sudo ln -s ../sites-available/code-server /etc/nginx/sites-enabled/code-marketplace

4. TLS with Let's Encrypt

sudo certbot --non-interactive --redirect --agree-tos --nginx -d mydomain.com -m [email protected]sudo systemctl restart nginx

5. TLS with self-signed certificate

You can use a tool like mkcert or generate one with openssl. For example:

mkdir /etc/nginx/certificatescd /etc/nginx/certificatesopenssl req -new -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out nginx-certificate.crt -keyout nginx.key

Update /etc/nginx/sites-available/code-marketplace using sudo with the following configuration:

server{listen80;server_name marketplace.example;return301 https://$server_name$request_uri/;}server{listen443ssl;server_name marketplace.example;ssl_certificate /etc/nginx/certificates/nginx-certificate.crt;ssl_certificate_key /etc/nginx/certificates/nginx.key;location / {proxy_passhttp://localhost:3001/;proxy_set_header X-Forwarded-Host $http_host;proxy_set_header X-Forwarded-Proto $scheme;}}

Then restart NGINX:

sudo systemctl restart nginx

6. DNS

Point marketplace.example to your server's IP address.

Clone this wiki locally