Skip to content

document usage with nginx #80

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

Closed
jerodev opened this issue Mar 7, 2019 · 9 comments
Closed

document usage with nginx #80

jerodev opened this issue Mar 7, 2019 · 9 comments
Labels
docs Documentation related

Comments

@jerodev
Copy link

jerodev commented Mar 7, 2019

  • code-server version: 1.31.1-100
  • OS Version: Debian 9

I have set up code-server on my server, and now I would like to access it externally. So I have set up a reverse proxy using Nginx. However when I navigate to the url I get an error in Chrome telling me that the page keeps redirecting (ERR_TOO_MANY_REDIRECTS).

If I shut down the code-server and go to the url I just get an error message, so this is correct.

server {
        listen 80;
        listen 443 ssl;
        ssl_certificate /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key /etc/nginx/ssl/nginx.key;

        server_name ide.server.com; # Removed real url

        location ~ ^/ {
                proxy_pass http://localhost:8443;
                proxy_set_header Host             $host;
                proxy_set_header X-Real-IP        $remote_addr;
                proxy_read_timeout 1800;
                proxy_connect_timeout 1800;

                auth_basic "Restricted";
                auth_basic_user_file /etc/nginx/.htpasswd;
        }
}
@ICEFIR
Copy link

ICEFIR commented Mar 7, 2019

Not too sure what happens to yours but....
Heres my nginx proxy script, it works...

server {
    listen 80;
    listen [::]:80;
    server_name something.something.com;
    location ~/ {
       proxy_pass http://localhost:8443;
       # Set WebSocket Proxy
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection upgrade;
    }
}

@kylecarbs
Copy link
Member

Should we add a guide for this?

@andreimc
Copy link

andreimc commented Mar 8, 2019

@kylecarbs might be helpful

@sebw
Copy link

sebw commented Mar 8, 2019

I was getting the same error trying to expose code-server with SSL using Traefik reverse proxy.

Make sure to pass --allow-http as option.

@nhooyr nhooyr added the docs Documentation related label Mar 8, 2019
@nhooyr nhooyr changed the title Nginx reverse proxy ERR_TOO_MANY_REDIRECTS document usage with nginx Mar 8, 2019
@NGTmeaty
Copy link
Contributor

Above was merged. Requesting close @nhooyr

@nhooyr nhooyr closed this as completed Mar 10, 2019
@nhooyr
Copy link
Contributor

nhooyr commented Mar 10, 2019

For posterity, the appropriate nginx docs are at http://nginx.org/en/docs/http/websocket.html

@EternalDeiwos
Copy link

May I suggest adding a link to the document added in #172 in the main README?

@kondr1
Copy link

kondr1 commented Oct 27, 2019

@code-asher can you make this manual again? After update code-server i already get ERR_TOO_MANY_REDIRECTS

@ralvs
Copy link

ralvs commented Apr 14, 2020

After hours trying, finally this config works for me. code-server v 3.1.0 at ubuntu 16

server {
    listen 80;

    server_name <my-server-name>;

    location / {
        proxy_pass http://localhost:8080;

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_redirect off;
    }   
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related
Projects
None yet
Development

No branches or pull requests

10 participants