Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Serving Django static files #6283

Unanswered
mskaif asked this question in Q&A
Jun 22, 2023 · 2 comments · 1 reply
Discussion options

Thank you so much for this project.

I have been trying to get Django to work with a Docker image for code-server from linuxserver.io. Everything works great so far except for static files. Code-server serves the Django app with a suffix /proxy/8000/. I have looked at the documentation and it says that code-server strips /proxy/ from the request path. This is true only for static files but is not ideal for the django development server. Static files are reachable when the suffix is added. I would really appreciate help setting up serving static files with a prefix /proxy/8000/ or any other suggestion

Many thanks!

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

code-server also has `/absproxy` which passes the request as-is so `/absproxy/8000/` instead might do the trick here. We currently have no way of choosing which proxy to use in the ports panel but it would be nice to add some kind of toggle in the future. For now you could manually change this by setting an environment variable, for example: ``` docker run --env 'VSCODE_PROXY_URI=https://domain.tld/absproxy/{{port}}/' codercom/code-server # Or use the more dynamic form //{{host}}/absproxy/{{port}}/ ``` Or you could of course manually type/change the URL. If you can get a wildcard certificate for your domain another idea is to use the subdomain proxy which circumvents all the issues with path-based routing. Lastly, I have seen mention of a method for configuring Django to work behind a rewriting reverse proxy; looks like you would have to set `FORCE_SCRIPT_NAME = /proxy/8000/` in `settings.py` but I have not tested that myself.
You must be logged in to vote
1 reply
Comment options

Thank you for your time and help!

I was trying to run code-server on a local server from another local machine. I have tried all combinations of different settings including the ones you suggested but none worked for django.
I have managed to run the code-server on apache2, ubuntu and published it on my site as a subdomain. However, I am still working on forwarding/adding reverse proxy for the development server traffic to the subdomain 8000.example.com. I'll update you on this later on.

Comment options

Anyone found a way to get Django working?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /