Jump to content
linuxserver.io

[Support] Linuxserver.io - Code-server

174 posts in this topic Last Reply

Recommended Posts

Is there some way to expose a locally running webserver that i started on the code-server terminal for development.

I have code-server running using swag for reverse proxy, everything is fine. I have a command to spin up a local web-server for web-dev needs (like hot-reloading etc). The command runs fine and starts a server on some port (lets say 8000). I'm unable to access that website of course.

 

Is there some recommended way to do this on code-server? I was looking for some plugins that would run a headless-chrome or something inside vs-code but they all seem to connect on the client side between browser and server. I also thought about exposing a specific port on the docker and on the proxy, but without luck. Even tho a web-server on port 8000 is runnin in the code-server terminal, i don't seem to be able to access it locally (without swag) even tho the port is exposed in the docker config.

Share this post


Link to post
9 minutes ago, martinjuhasz said:

Is there some way to expose a locally running webserver that i started on the code-server terminal for development.

I have code-server running using swag for reverse proxy, everything is fine. I have a command to spin up a local web-server for web-dev needs (like hot-reloading etc). The command runs fine and starts a server on some port (lets say 8000). I'm unable to access that website of course.

 

Is there some recommended way to do this on code-server? I was looking for some plugins that would run a headless-chrome or something inside vs-code but they all seem to connect on the client side between browser and server. I also thought about exposing a specific port on the docker and on the proxy, but without luck. Even tho a web-server on port 8000 is runnin in the code-server terminal, i don't seem to be able to access it locally (without swag) even tho the port is exposed in the docker config.

If you can't connect to the webserver at the port you have mapped in the container template, your webserver is not running.

It might also be a good idea to post the docker run command so we can see if you have mapped the port correctly.

Share this post


Link to post
1 hour ago, saarg said:

If you can't connect to the webserver at the port you have mapped in the container template, your webserver is not running.

It might also be a good idea to post the docker run command so we can see if you have mapped the port correctly.

my bad. the server was spun up using "localhost", not "0.0.0.0.", so it wasn't exposed to its LAN. Now it shows up on its localip:8000.

I'm still struggling to configure swag to forward this.

// Edit: nevermind: it shows up now, just took some minutes

 

So if anybody has a more elegant idea of doing this, let me know. I would love to be independent from ports as i might also have multiple instances running, that are connected just with "localhost". some tunneling would be awesome. but i guess that might not be achievable or even practical. in that case a VNC would make more sense.

 

 

 

 

Edited by martinjuhasz
works now

Share this post


Link to post
1 hour ago, martinjuhasz said:

my bad. the server was spun up using "localhost", not "0.0.0.0.", so it wasn't exposed to its LAN. Now it shows up on its localip:8000.

I'm still struggling to configure swag to forward this.

// Edit: nevermind: it shows up now, just took some minutes

 

So if anybody has a more elegant idea of doing this, let me know. I would love to be independent from ports as i might also have multiple instances running, that are connected just with "localhost". some tunneling would be awesome. but i guess that might not be achievable or even practical. in that case a VNC would make more sense.

 

 

 

 

I'm not quite sure what you want to achieve here, but you will never be able to run without ports. Somewhere you have to define the port.

You can remove the need to specify a port in the container template by running the containers in a custom network and take advantage of the DNS in the docker network. Doing this you have to have swag (which needs ports defined) and all container in the same custom network.

But you still have to define the ports in the proxy configs.

 

You can also take advantage of swag running your webserver, as it is a webserver.

Share this post


Link to post
4 hours ago, martinjuhasz said:

Is there some way to expose a locally running webserver that i started on the code-server terminal for development.

I have code-server running using swag for reverse proxy, everything is fine. I have a command to spin up a local web-server for web-dev needs (like hot-reloading etc). The command runs fine and starts a server on some port (lets say 8000). I'm unable to access that website of course.

 

Is there some recommended way to do this on code-server? I was looking for some plugins that would run a headless-chrome or something inside vs-code but they all seem to connect on the client side between browser and server. I also thought about exposing a specific port on the docker and on the proxy, but without luck. Even tho a web-server on port 8000 is runnin in the code-server terminal, i don't seem to be able to access it locally (without swag) even tho the port is exposed in the docker config.

Code-server already has that functionality built in where it can proxy a service on a port via the port as a sub-subdomain.

 

Look into the proxy_domain env var

Share this post


Link to post

Getting blank page when navigating to code-server behind LE/SWAG

 

  • I deployed the image stock - set it to my SWAG network
  • Added a new domain and CNAME ("code-server" on namecheap DNS)
  • Copied the 'code-server....sample' proxy-confs and just added my domain to the "server_name" line and left everything else alone (per other comments here)
  • Updated SWAG docker with new domain and bounced SWAG and verified it comes up clean

 

I can hit the new domain and it prompts for the web gui PW and right after authenticating, it just goes to a blank screen

 

??

Share this post


Link to post
4 hours ago, dharrah said:

Getting blank page when navigating to code-server behind LE/SWAG

 

  • I deployed the image stock - set it to my SWAG network
  • Added a new domain and CNAME ("code-server" on namecheap DNS)
  • Copied the 'code-server....sample' proxy-confs and just added my domain to the "server_name" line and left everything else alone (per other comments here)
  • Updated SWAG docker with new domain and bounced SWAG and verified it comes up clean

 

I can hit the new domain and it prompts for the web gui PW and right after authenticating, it just goes to a blank screen

 

??

Have you tried a different browser or private mode?

Share this post


Link to post
5 hours ago, saarg said:

Have you tried a different browser or private mode?

Yes - Chrome/Incognito is my primary browser, but I also tried IE and Firefox. Also Safari on my phone - same thing with the login page coming up first and then it goes blank after entering the password.

Share this post


Link to post
1 hour ago, dharrah said:

Yes - Chrome/Incognito is my primary browser, but I also tried IE and Firefox. Also Safari on my phone - same thing with the login page coming up first and then it goes blank after entering the password.

Is this inside your network or using cellular data?

Share this post


Link to post
1 minute ago, saarg said:

Is this inside your network or using cellular data?

Both - same results either way
As I look at the browser console logs, I see a few errors:

WebSocket handshake - error 200
WebSocket closed with status code 1006

I still have the stock proxy-confs file in place - no changes were made. But the fact that I get the login page at my domain address seems to indicate that the SWAG portion of things is "fine". 

 

 

codeserverError.png

Share this post


Link to post
5 hours ago, dharrah said:

Both - same results either way
As I look at the browser console logs, I see a few errors:

WebSocket handshake - error 200
WebSocket closed with status code 1006

I still have the stock proxy-confs file in place - no changes were made. But the fact that I get the login page at my domain address seems to indicate that the SWAG portion of things is "fine". 

 

 

codeserverError.png

Make sure your nginx confs (ssl, proxy, nginx, etc.) are up to date. If you didn't customize them, you can delete them and restart the container. There was recently a change regarding websockets.

Share this post


Link to post
6 hours ago, aptalca said:

Make sure your nginx confs (ssl, proxy, nginx, etc.) are up to date. If you didn't customize them, you can delete them and restart the container. There was recently a change regarding websockets.

That worked!
I created a new folder in /home and then moved the following files from /config/nginx:

 

  • nginx.conf
  • ldap.conf
  • ssl.conf
  • proxy.conf

 

After bouncing SWAG, I was able to connect just fine!

 

Thanks @aptalca

 

Edited by dharrah

Share this post


Link to post

Hi, I have the same Problem "WebSocket close ..." I really don't know when it did stop working. I upgraded from letsencrypt to swag maybe two weeks ago (maybe since then). I did drop the files (nginx.conf, ldap.conf, ssl.conf, proxy.conf) into a temp folder and restart the swag container... the files did get newly created. But it still does not work. Any ideas? thx

Share this post


Link to post
4 hours ago, odiby said:

Hi, I have the same Problem "WebSocket close ..." I really don't know when it did stop working. I upgraded from letsencrypt to swag maybe two weeks ago (maybe since then). I did drop the files (nginx.conf, ldap.conf, ssl.conf, proxy.conf) into a temp folder and restart the swag container... the files did get newly created. But it still does not work. Any ideas? thx

Just to confirm, can you explain what exactly isn't working? 
Also, can you post your SWAG conf file for code-server?

Share this post


Link to post
On 9/20/2020 at 5:12 PM, aptalca said:

Code-server already has that functionality built in where it can proxy a service on a port via the port as a sub-subdomain.

 

Look into the proxy_domain env var

Do you have some more information on that @aptalca? I have a subdomain set up using proxy_domain and swag, but am not able to find anything online about sub-subdomain configuration. 

Share this post


Link to post
10 hours ago, martinjuhasz said:

Do you have some more information on that @aptalca? I have a subdomain set up using proxy_domain and swag, but am not able to find anything online about sub-subdomain configuration. 

It's code server functionality and it's explained in their docs. Our image supports the domain name setup via env var and swag's built-in proxy conf allows it by default.

 

You just need to add "*.code-server.yourdomain.com" to extra domains in swag so your cert covers the sub-subdomains of code server.

(Or XXXX.code-server.yourdomain.com of your doing http validation and can't do wildcard)

Share this post


Link to post

Does anyone know how to get to the preview page from the Live Server extension?  I saw someone asking about the extension in the past but I think my question is different - Live Server says it's running and that it's running on port 5500.  Normally you would go to 127.0.0.1:5500/index.html if you were using VS Code on your local workstation but since it's a docker container that wouldn't/doesn't work like that - I tried adding a  few ports to the docker configuration to try and let me access ports 5500 through 5505 from my LAN but that didn't work either.  A screen shot of the port 5500 config that I tried to add.  I just did this 6 times for 5500, ..., 5505.

 

This may be more of a routing question than a code-server question, but if anyone here can help me out I'd appreciate it!

 

image.png.aaf95db811ae4c4e6c3dc2474aeb6a48.png

Share this post


Link to post
1 hour ago, romain said:

Does anyone know how to get to the preview page from the Live Server extension?  I saw someone asking about the extension in the past but I think my question is different - Live Server says it's running and that it's running on port 5500.  Normally you would go to 127.0.0.1:5500/index.html if you were using VS Code on your local workstation but since it's a docker container that wouldn't/doesn't work like that - I tried adding a  few ports to the docker configuration to try and let me access ports 5500 through 5505 from my LAN but that didn't work either.  A screen shot of the port 5500 config that I tried to add.  I just did this 6 times for 5500, ..., 5505.

 

This may be more of a routing question than a code-server question, but if anyone here can help me out I'd appreciate it!

 

image.png.aaf95db811ae4c4e6c3dc2474aeb6a48.png

Perhaps live server needs to bind 0.0.0.0 so it's accessible from outside the container as opposed to bonding 127.0.0.1 which would only be accessible from inside the container

Share this post


Link to post
4 minutes ago, aptalca said:

Perhaps live server needs to bind 0.0.0.0 so it's accessible from outside the container as opposed to bonding 127.0.0.1 which would only be accessible from inside the container

Thanks for the idea.  I'll look into doing that.

Share this post


Link to post

I've got another question - I was on version 3.6.0 and had updated git to 2.29.x.  Today I let unRAID update code-server to 3.6.1 and after the update git was back on 2.17, is there a way to keep git up to date through container updates or will I just need to do a manual update every time the container updates?

Share this post


Link to post
8 hours ago, romain said:

I've got another question - I was on version 3.6.0 and had updated git to 2.29.x.  Today I let unRAID update code-server to 3.6.1 and after the update git was back on 2.17, is there a way to keep git up to date through container updates or will I just need to do a manual update every time the container updates?

How did you update it? The bionic repo has 2.17 

Share this post


Link to post
8 hours ago, aptalca said:

How did you update it? The bionic repo has 2.17 

I updated git through the docker console.image.png.73d5e6e0c7a14d654c6e4ee8d663dfeb.png

 

I had to run this:

sudo apt update
sudo apt upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

after those all finished I was on 2.29.1 or 2.29.2 or something.

Share this post


Link to post
5 hours ago, romain said:

I updated git through the docker console.image.png.73d5e6e0c7a14d654c6e4ee8d663dfeb.png

 

I had to run this:


sudo apt update
sudo apt upgrade
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

after those all finished I was on 2.29.1 or 2.29.2 or something.

Then you'll have to create a custom script that does those steps for you during container start: https://blog.linuxserver.io/2019/09/14/customizing-our-containers/

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.