@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
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
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).
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-stoppedAny 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