-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Nginx not redirecting correctly on fresh local install #2836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @coamtaker618 - thanks for the extra details in the issue and sorry to hear you're having trouble! Apologies, I have not set code-server up manually with nginx. Have you already looked through nginx-related discussions? Here are two that seem directly related to the issue you're running into: |
I have been using the nginx with SSL successfully for almost an year. @coamtaker618 could you please try the below nginx settings and let us know. `server {
}` @jsjoeio requesting you to test and confirm it. |
Thanks chimming in @balajib-b! 🙌 Added this to the current milestone. Hoping I can find time to try it myself and see if it works. |
Still no luck :( See below for my nginx page. The only thing I changed after copy/paste is my server URL I had a line " listen 80;" but got rid of that since you didn't have it. Didn't seem to make a difference. If I navigate to 8080 directly, it seems to work fine (I get a login prompt & vscode when I login)--but navigating to port 80 I still get a 502 (Bad Gateway). And I did make sure to restart nginx after changing the file :)
|
@jsjoeio I did try searching for NGINX issues with code-server but I certainly could have missed something! #2593 may be exactly my problem but there was no further communication from poster, and the recommended suggestion was "check if code-server" is actually running. Certainly good advice, but I know it is because I can get to it on port 8080. #2607 seems like a more complex setup, but also no further communication from the OP :( The nginx setup seems to be more complicated than mine, and so most of the advice doesn't apply. That said, I'd be happy to check nginx logs if I knew how >_< |
@coamtaker618 you are accessing code server using associated domain name or using IP address. @jsjoeio there had been a discussion on another thread about the one click deployment to clouds. I am willing to help regarding cloud deployment. Let me know your interest and support from your side. |
@balajib-b I'm using a domain (strictly a subdomain of a domain that I own). I have a few other services I'm hosting so I don't think the problem is a bad domain, but it never hurts to check! |
Email sent |
Sorry to hear that didn't help much @coamtaker618 - we'll see if we can take a look. @balajib-b regarding the one-click deployments - thanks for offering some help! @bpmct was leading the effort and actually merged a PR yesterday: #2843 Feel free to open a new Discussion and tag myself if you have more ideas or want to get more involved! |
Try change this:
to this:
and see if that works. Regards, Martinus |
@martinussuherman gave that a try & no change. But thanks for the suggestion! |
@coatmaker618 sorry to hear that. Btw, I've made a repo for code-server nginx configuration here: https://github.com/martinussuherman/code-server-nginx-config based on my live setup (using docker/docker-compose for both nginx and code-server). Please take a look and hope it could help you solve your problem. @jsjoeio if you have any input or suggestion on the above repo please let me know. Thanks. Regards, Martinus |
@martinussuherman awesome! If you can add a If you need inspiration, this is the template I always use. |
@jsjoeio thanks for the suggestion and template info. I'll try make the readme asap. Regards, Martinus |
can confirm @martinussuherman's config stuff worked ( for at least getting to the application, haven't tested much more than that). I swapped out the here are my configs ( with the domain stripped ), and after I ran certbot to install my certificate:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "Upgrade";
proxy_cache_bypass $http_upgrade;
server {
server_name <domain>;
set $backend 127.0.0.1:8080;
location / {
try_files /nonexistent @$http_upgrade;
}
location @websocket {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding gzip;
proxy_pass http://$backend;
include /etc/nginx/snippets/websocket-proxy.conf;
}
location @WebSocket {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding gzip;
proxy_pass http://$backend;
include /etc/nginx/snippets/websocket-proxy.conf;
}
location @ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Accept-Encoding gzip;
proxy_pass http://$backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection keep-alive;
proxy_cache_bypass $http_upgrade;
}
location ~ \.(php|cgi|bin)
{
return 444;
}
autoindex off;
index index.html;
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = <domain>) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name <domain>;
listen 80;
return 404; # managed by Certbot
} |
@martinussuherman Awesome to see that nginx config works! I will take a look soon and see how we can feature this setup on here awesome-code-server |
@elreydetoda I'm glad that it works for you. Regards, Martinus |
even with @martinussuherman configuration for both nginx and code-server in separate docker containers, i have not been able to get remote access to code-server. I'm still seeing 502 errors. |
I was having the same issue, and I was using oracle linux and this seems to be issue with other flavors like centos. Running the solution stated in https://stackoverflow.com/questions/23948527/13-permission-denied-while-connecting-to-upstreamnginx -> I was getting access denied in /var/log/nginx/error.log |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days. |
Tried to follow the installation on this github page and I was able to get code-server installed, but I cannot get nginx to point to it successfully!
Background: I am selfhosting this service on it's own VM. After following the instructions on this github page I was able to navigate to the code-server http URL. However, the prescribed nginx code gives me a 502 (bad gateway) rather than the desired page. Before deleting the default nginx page (not listed in instructions), I DID get the "welcome to nginx" page, so it would seem nginx is installed correctly. I'm sure it's something simple, and yes, I did change the URL in "server_name".
Any advice would be appreciated, and once i get this running, I'd be happy to update the docs for a self-hosted instructions if desired.
Reporting Disclaimer: This may be fixed with a documentation change, but as it's preventing VSCode from being usable, I'm currently considering it a bug.
The text was updated successfully, but these errors were encountered: