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.

NGINX Proxy Pass with SSL Support

See original GitHub issue

This is my nginx proxy pass configuration for planka (with SSL).

server {
    server_name planka.url;

    listen 443 ssl;                                                         
    listen [::]:443 ssl;

    location / {
        proxy_pass      http://127.0.0.1:1337;
        include         proxy_params;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:13

github_iconTop GitHub Comments

4reactions
meltyshevcommented, Aug 24, 2020

This is what i have

ports: - 127.0.0.1:1337:1337 environment: - BASE_URL=http://127.0.0.1:1337

I even tried ports: - 127.0.0.1:1337:1337 environment: - BASE_URL=http://planka.test.com:1337

Hi, @Git-Cluster! BASE_URL should contain exactly the same host as server_name from nginx config. Try something like this: BASE_URL=https://planka.test.com (it should have an https scheme and without port).

3reactions
tricooscommented, Jun 16, 2021

Just in case - here is my working config:

nginx.conf

server {
    listen 80;
    server_name tasks.example.com tasks;
    return 301 https://tasks.example.com$request_uri;
}

map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
}

server {
        listen                  443 ssl;
        server_name             tasks.example.com;
        ssl_certificate         /certs/tasks.example.com.crt;
        ssl_certificate_key     /certs/tasks.example.com.key;

        if ($host != $server_name) {
            return 301 https://tasks.example.com$request_uri;
        }

        location /socket.io {
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
              proxy_http_version 1.1;
              proxy_pass http://planka:1337/socket.io;
        }

        location / {
                proxy_pass http://planka:1337;
        }
}

in docker-compose.yml BASE_URL=https://tasks.example.com

I never saw any 400 Bad Request in Chrome, however when I switched to Firefox I was finally able to see the 400 error. After then changing the BASE_URL and restarting the Docker container (!) it started working!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Securing HTTP Traffic to Upstream Servers | NGINX Plus
NGINX will identify itself to the upstream servers by using an SSL client certificate. This client certificate must be signed by a trusted...
Read more >
Nginx proxy_pass to https - reverse proxy
i want to pass this traffic to my server with the ip address 192.168.0.10. On this server i have ssl enabled listen port...
Read more >
proxy - nginx proxy_pass to https
The solution is to make sure you have certificates installed and ssl enabled for the port in question and that any proxy_pass does...
Read more >
How To Configure Nginx with SSL as a Reverse Proxy for ...
This post will detail how to wrap your site with SSL using the Nginx web server as a reverse proxy for your Jenkins...
Read more >
How to Use NGINX as an HTTPS Forward Proxy Server
NGINX was initially designed as a reverse proxy server. However, with continuous development, NGINX also serves as one of the options to ...
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