question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

document usage with nginx

See original GitHub issue
  • 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;
        }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

17reactions
ralvscommented, 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;
    }   
}
17reactions
ICEFIRcommented, 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;
    }
}

Read more comments on GitHub >

github_iconTop Results From Across the Web

Full Example Configuration - NGINX
A full-fledged example of an NGINX configuration.
Read more >
nginx documentation - Nginx.org
nginx documentation. Introduction. Installing nginx · Building nginx from Sources · Beginner's Guide · Admin's Guide · Controlling nginx ...
Read more >
Understanding the Nginx Configuration File Structure and ...
The Nginx documentation contains information about which contexts ... Defining an HTTP context is probably the most common use of Nginx.
Read more >
openresty/lua-nginx-module: Embed the Power of ... - GitHub
This document interchangeably uses the terms "Lua" and "LuaJIT" to refer to the LuaJIT interpreter. By leveraging Nginx's subrequests, this module allows ...
Read more >
ConfigMap - NGINX Ingress Controller - Kubernetes
name type default add‑headers string "" allow‑backend‑server‑header bool "false" allow‑snippet‑annotations bool true
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found