Using reverse proxy to expose code-server to the internet

2.3k Views Asked by At

I have installed code-server on my Plesk VPS, and i was wondering how to expose it to the outside world using a reverse proxy. Currently code-server is bound to 127.0.0.1:8080, and if i use wget via SSH i get the expected page. How do i go about exposing code-server to the internet (using reverse proxy) on Plesk/CentOS

I’ve tried using vhost_nginx.config file but to no luck

location ~ / {
  proxy_pass          http://localhost:8080;
  proxy_read_timeout  90;
}
1

There are 1 best solutions below

0
M Taufiq Permana S On

You can try using my nginx config, change app URL and app port if needed, put it in /etc/nginx/sites-available than use symlink to /etc/nginx/sites-enabled, and don't forget to restart nginx.

server {
    listen 80;
    server_name example.com; #change app url
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://127.0.0.1:8080; #change app port
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        # location /overview {
        #     proxy_pass http://127.0.0.1:8080$request_uri; #change app port
        #     proxy_redirect off;
        # }
    }
}