@Agastya-Asthana
Here is a very good docker-run to help you with HTTP

STEP 1
Generate the self signed certificate file
GENERATE CRT AND KEY FILE IN THE CERTS DIRECTORY
openssl req
-newkey rsa:2048 -nodes -keyout certs.key
-x509 -days 365 -out certs.crt

STEP 2
Make a certs folder in your current working directory and then use below docker run
Replace your-username-here in the below docker-run with your current user.

STEP 3
docker run -it --rm --name code-server-https -p 0.0.0.0:8080:8080 -v "$(pwd)/CodeServer/.config:/home/coder/.config" -v "$(pwd)/VSCodes:/home/coder/project" -u "(id -g)" -v $(pwd)/CodeServer/certs/certs.crt:/home/coder/cert.crt -v $(pwd)/CodeServer/certs/certs.key:/home/coder/cert.key -e "DOCKER_USER=your-username-here" -e "USER=your-username-here" codercom/code-server:latest --cert /home/coder/cert.crt --cert-key /home/coder/cert.key

STEP 4
All done, you should be good to go. Now bash in to the container and see that code-server is serving with HTTPS.

@Agastya-Asthana ### Please mark this discussion as answered if your query has been solved.
Thank You

🌐
Reddit
reddit.com › r/selfhosted › selfhost code-server, but can not get https working
r/selfhosted on Reddit: selfhost code-server, but can not get https working
July 21, 2024 -

HI folks, need some help here?

so i have a ubuntu server, installed code-server through official script, running fine on port 7001, i have pi-hole dns point example and example.com to server ip, so i can access code-server through example:7001, when i am away from home, i can access through tailscale (tailscale magic dns point example to the ubuntu server too).

Now i try to set up https for code-server, so i followed this tutorial to generate cert and key and systemctl restart code-server, but when i load it through example.com:7001, the browser still complains, i "proceed anyway" but there is still issue opening, for example, .ipynb file, "error: Could not register service worker: SecurityError: Failed to register a ServiceWorker for scope ", what am i missing here?? Thanks in advance

Top answer
1 of 4
4
+1 for nginx proxy manager. It does https via let's encrypt and you can do wildcard certificates.
2 of 4
3
Few different ways of doing https: self-signed cert.  It’ll work and the data will be encrypted, but your browsers and apps will complain that it’s not secure since they can’t verify the host. deploying your own certificate authority (CA) and using that to sign your cert.  This will get rid of the complaints from your client, but only if you go install the CA docs into every machine you want to connect to the host with, which sucks. Let’s Encrypt (or similar) http challenge.  This is easy and reliable and gets rid of all warnings, but you must open up a port in your firewall so the Let’s Encrypt servers can verify you really do own the domain.  You only need to open the port when renewing the cert, but that means you’ll have to re-open it, renew, and close it back every 3 months.  Not terrible if it’s just one server you have to do this for, but it gets ugly quickly when you start adding more.  Or you can just leave your server permanently exposed to incoming connections from the internet, but that’s not a great idea for security unless it’s absolutely necessary. Let’s Encrypt (or similar) dns challenge.  This requires you own a domain from one of the supported domain hosts, but otherwise it’s painless - assuming the service you’re setting up supports it, most don’t, or they make it difficult.  But it lets you get a real cert that keeps all your clients happy, and it’ll auto-renew, and you don’t have to go punching holes in the firewall. A combination of #1 and #4 using a reverse proxy.  You set up a reverse proxy like nginx or caddy with a dns-challenge wildcard cirt that auto-renews and is valid for any subdomain at your domain.  The reverse proxy then forwards the connection on to your server, which should also be set up with https (so the connection is encrypted), but the cert doesn’t matter for that half, so you can use any self-signed or expired cert that you want and your client machines won’t know the difference.
🌐
Stack Overflow
stackoverflow.com › questions › 61386014 › problem-in-running-code-server-in-https-secure
docker - Problem in running code-server in https secure - Stack Overflow
If we run docker run -d -p 8080:8080 sanjayme/vscode-dotnet-core --auth none --cert still we are facing not secure connection. How to solve this? ... docker \ -v /path/to/certs.crt:/home/coder/cert.crt \ -v /path/to/cert-key.key:/home/coder/cert.key \ -p 8080:8080 \ run codercom/code-server:v2 \ --cert /home/coder/cert.crt --cert-key /home/coder/cert.key · the http url is working, but if we browse https dns mapped url it's throwing an error.
🌐
GitHub
github.com › coder › code-server › issues › 1109
[v2.1638-vsc1.39.2] Unable to start latest CS with HTTPS · Issue #1109 · coder/code-server
October 25, 2019 - Release notes state... If you aren't doing SSL termination elsewhere you can directly give code-server a certificate with code-server --cert followed by the path to your certificate. Additionally, you can use certificate keys with --cert-key followed by the path to your key.
🌐
Reddit
reddit.com › r/homeserver › failed to access my code-server with my https domain
r/HomeServer on Reddit: Failed to access my code-server with my https domain
January 23, 2024 -

Hi,

I try to expose my code-server to the Internet with a registered domain name with nginx. I did everything in the documentation page (https://coder.com/docs/code-server/latest/guide#using-lets-encrypt-with-nginx) but I got a SSL error in the end.

Nginx is setup with this config (the same in the code-server doc). When I simply access "mydomain.com" with https (no port indicated), I got a working nginx welcome page.

server {

listen 80;

listen [::]:80;

server_name mydomain.com;

ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;

ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;

location / {

proxy_pass http://localhost:8080/;

proxy_set_header Host $http_host;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection upgrade;

proxy_set_header Accept-Encoding gzip;

}

}

Like indicated, I enabled my symbolic link and got a SSL certificate successfully :

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

  • sudo certbot --non-interactive --redirect --agree-tos --nginx -d mydomain.com -m me@example.com

Code-server is working on http (with the "connection is not secure" warning), but not on https. When I tried with port 8080 (https://mydomain.con:8080)). I got "secured connection failed", "Error code: SSL_ERROR_RX_RECORD_TOO_LONG".

UFW have ports opened. My code-server is mount in docker with a pretty simple "compose file" :

services:

code-server:

image: codercom/code-server:latest

container_name: code-server

restart: always

ports:

- 8080:8080

volumes:

- ./code-server:/home/coder/project

- ./code-server/.local:/home/coder/.local"

- ./code-server/.config:/home/coder/.config"

environment:

- PUID=1000

- PGID=1000

- PASSWORD=alegitpasswordhere

Someone has the answer? Thanks a lot!

(obviously, "mydomain.com" and password are replaced in my config files).

🌐
GitHub
github.com › coder › code-server › issues › 1548
how to run code server in https · Issue #1548 · coder/code-server
April 23, 2020 - if we run "docker run -d -p 8080:8080 sanjayme/vscode-dotnet-core --auth none --cert" still we are facing not secure connection how to solve this. even we tried something similar to "docker -v /pat...
Author   sanjayme97
🌐
GitHub
github.com › coder › code-server › issues › 1101
code-server --cert fails and code-server --cert "" starts the server without SSL · Issue #1101 · coder/code-server
October 24, 2019 - coder / code-server Public · Notifications · You must be signed in to change notification settings · Fork 6.3k · Star 74.5k · New issueCopy link · New issueCopy link · Closed · Closed · code-server --cert fails and code-server --cert "" starts the server without SSL#1101 ·
Author   wpitallo
🌐
GitHub
github.com › coder › code-server › discussions › 4884
404? NOT serving HTTPS · coder/code-server · Discussion #4884
这个好像是你不指定code-server的证书不开启https就显示这个NOT serving HTTPS.
Author   coder
Find elsewhere
🌐
GitHub
github.com › coder › code-server › issues › 2513
Not Serving HTTPS · Issue #2513 · coder/code-server
December 24, 2020 - I am trying to dockerize the code-server for armv7 systems. When I run the code-server command in the container is outputs a bunch of logs and the last one is "[2020-12-24T03:49:41.745Z] info - Not serving HTTPS." I have my docker container mapping port 8080 of host to the container's.
Author   Agastya-Asthana
🌐
Ask Ubuntu
askubuntu.com › questions › 1249549 › code-server-on-ubuntu-not-working
18.04 - Code-Server on Ubuntu not working - Ask Ubuntu
info code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f info HTTP server listening on http://127.0.0.1:8443 info - Password is `somepassword` info - To use your own password set the PASSWORD environment variable info - To disable use `--auth none` info - Not serving HTTPS info Automatic updates are enabled
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-set-up-the-code-server-cloud-ide-platform-on-ubuntu-20-04
How To Set Up the code-server Cloud IDE Platform on Ubuntu 20.04 | DigitalOcean
May 20, 2020 - May 20 13:03:40 code-server-update-2004 code-server[15010]: info Wrote default config file to ~/.config/code-server/config.yaml May 20 13:03:40 code-server-update-2004 code-server[15010]: info Using config file ~/.config/code-server/config.yaml May 20 13:03:40 code-server-update-2004 code-server[15010]: info Using user-data-dir /var/lib/code-server May 20 13:03:40 code-server-update-2004 code-server[15010]: info code-server 3.3.1 6f1309795e1cb930edba68cdc7c3dcaa01da0ab3 May 20 13:03:40 code-server-update-2004 code-server[15010]: info HTTP server listening on http://127.0.0.1:8080 May 20 13:03:40 code-server-update-2004 code-server[15010]: info - Using password from $PASSWORD May 20 13:03:40 code-server-update-2004 code-server[15010]: info - To disable use `--auth none` May 20 13:03:40 code-server-update-2004 code-server[15010]: info - Not serving HTTPS
🌐
GitHub
github.com › coder › code-server › issues › 1800
code-server 3.2.0 starting but can't access the website · Issue #1800 · coder/code-server
June 12, 2020 - info code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f info HTTP server listening on http://127.0.0.1:8080 info - Password is `somepassword` info - To use your own password set the PASSWORD environment variable info - To disable use `--auth none` info - Not serving HTTPS info Automatic updates are enabled
Author   MrHelloSir
🌐
Reddit
reddit.com › r/selfhosted › code-server from linuxserver
r/selfhosted on Reddit: Code-server from Linuxserver
February 4, 2023 -

I have been trying to figure out the issue of this container. If I try to access it from the web-browser, I get 502 error. I tried to curl it from a different VM, I get connection refused. I don't think it is related, but I added 8445/tcp to the firewalld, but I still getting an error. Below is my docker-compose.yml file

---
version: "2.1"
services:
  code-server:
    env_file: .env
    image: lscr.io/linuxserver/code-server:latest
    container_name: code-server
    environment:
      - PUID=1001
      - PGID=1001
      - TZ=UTC
      - PASSWORD=password #optional
        #- HASHED_PASSWORD= #optional
      - SUDO_PASSWORD=password #optional
        #- SUDO_PASSWORD_HASH= #optional
        #- PROXY_DOMAIN=${PROXYDOMAIN} #optional
      - DEFAULT_WORKSPACE=/config/workspace #optional
    volumes:
      - /mnt/disk1/appdata/code-server:/config
    ports:
      - 8445:8443
    restart: unless-stopped

Any idea what could be the issue and why the container is not opening the port 8445. I tried to switch it to the default port 8443 and I still get the same 502 on browsers and connection refused from curl.

EDIT: added the logs.

code-server    | [migrations] started
code-server    | [migrations] no migrations found
code-server    | 
code-server    | -------------------------------------
code-server    |           _         ()
code-server    |          | |  ___   _    __
code-server    |          | | / __| | |  /  \
code-server    |          | | \__ \ | | | () |
code-server    |          |_| |___/ |_|  \__/
code-server    | 
code-server    | 
code-server    | Brought to you by linuxserver.io
code-server    | -------------------------------------
code-server    | 
code-server    | To support LSIO projects visit:
code-server    | https://www.linuxserver.io/donate/
code-server    | -------------------------------------
code-server    | GID/UID
code-server    | -------------------------------------
code-server    | 
code-server    | User uid:    1001
code-server    | User gid:    1001
code-server    | -------------------------------------
code-server    | 
code-server    | setting up sudo access
code-server    | adding abc to sudoers
code-server    | setting sudo password using SUDO_PASSWORD env var
code-server    | New password: Retype new password: passwd: password updated successfully
code-server    | [custom-init] No custom files found, skipping...
code-server    | [2023-02-04T16:37:53.638Z] info  code-server 4.9.1 f7989a4dfcf21085e52157a01924d79d708bcc05
code-server    | [2023-02-04T16:37:53.639Z] info  Using user-data-dir ~/data
code-server    | [2023-02-04T16:37:53.663Z] info  Using config file ~/.config/code-server/config.yaml
code-server    | [2023-02-04T16:37:53.663Z] info  HTTP server listening on http://0.0.0.0:8445/ 
code-server    | [2023-02-04T16:37:53.664Z] info    - Authentication is enabled
code-server    | [2023-02-04T16:37:53.664Z] info      - Using password from $PASSWORD
code-server    | [2023-02-04T16:37:53.664Z] info    - Not serving HTTPS 

🌐
Stack Overflow
stackoverflow.com › questions › 73611837 › vscode-server-serve-local-extension-content-is-not-showing
visual studio code - vscode-server serve-local extension content is not showing - Stack Overflow
I decided to install code-server at home and installed it in a docker container on one of my Raspberry Pi 4's. I created a host for the container called vscode.local. Works great but, I had the same problem you were having. Per the documentation https://coder.com/docs/code-server/latest/ipad, using coder-server local you're most likely accessing coder-server with http and not https.
🌐
GitHub
github.com › coder › code-server › discussions › 3757
WebViews do not load with https and self signed certificates · coder/code-server · Discussion #3757
This issue is worrying me a lot, the webviews in code-server is not working. I googled and came up with this solution to ignore certificate errors, and this is the command. google-chrome --ignore-certificate-errors --unsafely-treat-insecure-origin-as-secure=https://192.168.0.120:8080 --user-data-dir=/tmp/foo
Author   coder
🌐
GitHub
github.com › coder › code-server › issues › 2708
Unable to connect with --link · Issue #2708 · coder/code-server
February 10, 2021 - #2704 isn't resolved, sorry. code-server --link [2021-02-10T16:53:51.032Z] info HTTP server listening on http://**127.0.0.1**:32947 (randomized by --link) There no way --link can access my server at 127.0.0.1, as it's hosted remotely. It...
Author   accesstechnology-mike
🌐
Medium
chanwkim01.medium.com › how-to-set-up-code-server-daemon-on-ubuntu-root-access-docker-systemd-nginx-reverse-proxy-and-a72fa80e02e9
How to Set Up code-server daemon on Ubuntu for Deep Learning: Root Access, Docker, systemd, NGINX Reverse-Proxy, and More | by Chan Woo Kim | Medium
December 31, 2021 - ubuntu@server-1312:~/myname$ code-server [2021-06-23T03:54:38.221Z] info code-server 3.10.2 387b12ef4ca404ffd39d84834e1f0776e9e3c005 [2021-06-23T03:54:38.222Z] info Using user-data-dir ~/.local/share/code-server [2021-06-23T03:54:38.237Z] info Using config file ~/.config/code-server/config.yaml [2021-06-23T03:54:38.237Z] info HTTP server listening on http://127.0.0.1:8080 [2021-06-23T03:54:38.237Z] info - Authentication is enabled [2021-06-23T03:54:38.237Z] info - Using password from ~/.config/code-server/config.yaml [2021-06-23T03:54:38.237Z] info - Not serving HTTPS