code-server icon indicating copy to clipboard operation
code-server copied to clipboard

[Feat]: Support `HOST` env to override binding host

Open zanminkian opened this issue 2 years ago • 2 comments

What is your suggestion?

Now, we can change the binding host by passing arg --bind-addr. For example, --bind-addr=127.0.0.1:8080, --bind-addr=0.0.0.0:8080.

And, we can set PORT env to override the binding port. Why can't HOST to override the binding host?

Therefore, I hope we can use HOST env to override binding host. Thanks!

Why do you want this feature?

HOST env and PORT env should behave the same, I think.

And, I can edit my .bashrc or .zshrc to change the HOST env. It would be convenient for some people like me.

Are there any workarounds to get this functionality today?

No.

Are you interested in submitting a PR for this?

Sorry that I don't know how to do.

zanminkian avatar Feb 13 '23 05:02 zanminkian

@zanminkian instead of setting the variables for the user, you can set the contents of the file /home/$USER/.config/code-server/config.yaml as below

bind-addr: HOST:PORT auth: password password: "your desired password without quotes"

this will ensure that the user code-server@USER service picks up the corresponding USER config file from above mentioned location and start the service.

It might not be a good idea to configure .bashrc file with HOST and PORT variables, since this variable becomes common to the bash env and used by all applications. so, i would recommend you to use to config file.

balajib-b avatar Feb 13 '23 05:02 balajib-b

@balajib-b Thanks. I know $HOME/.config/code-server/config.yaml config file, but I still want to use HOST env. Controlling some behaviors of code-server by pass env variables will be convenient in some cases. For example, we can deploy official docker image to some platform. But many platforms only support to pass env variables to the container.

Maybe we should rename PORT to CS_PORT and HOST to CS_HOST.

zanminkian avatar Feb 13 '23 06:02 zanminkian