[Support] Linuxserver.io - Code-server


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.

Link to comment
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.

Link to comment
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
Link to comment
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.

Link to comment
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

Link to comment

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

 

??

Link to comment
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?

Link to comment
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?

Link to comment
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

Link to comment
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.

Link to comment
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
Link to comment
  • 3 weeks later...

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

Link to comment
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?

Link to comment
  • 2 weeks later...
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. 

Link to comment
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)

Link to comment
  • 2 weeks later...

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

Link to comment
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

Link to comment

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?

Link to comment
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 

Link to comment
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.

Link to comment
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/

Link to comment
  • 2 months later...

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.