plankanban / planka

The realtime kanban board for workgroups built with React and Redux.
https://planka.app
GNU Affero General Public License v3.0
7.92k stars 736 forks source link

NGINX Proxy Pass with SSL Support #21

Closed gamelaster closed 1 year ago

gamelaster commented 4 years ago

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";
    }
}
ghost commented 4 years ago

Doesn't work for me. How does your docker-compose yml file looks like? 3000-> 1337?

gamelaster commented 4 years ago

@Git-Cluster

ports:
      - 127.0.0.1:1337:1337

So I just bind local 1337 port for 1337 port in container. Also, my docker-compose.yaml is based on original one without any much changes. (BTW, my nginx is running on host)

ghost commented 4 years ago

@Git-Cluster

ports:
      - 127.0.0.1:1337:1337

So I just bind local 1337 port for 1337 port in container. Also, my docker-compose.yaml is based on original one without any much changes. (BTW, my nginx is running on host)

This is what i have

` ports:

I even tried ` ports:

And the nginx config is exactly the same as yours

` server { server_name planka.test.com;

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";
}

} `

Websockets still ain't connected properly.

Mind if I get some help?

Thanks!

gamelaster commented 4 years ago

Please, can you check what is in your Devtools console (according to gif down)? There should be and error message. 2020-08-24_08-13-38

ghost commented 4 years ago
2websocket.js:124 WebSocket connection to 'wss://planka.test.com/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
p.doOpen @ websocket.js:124
3websocket.js:124 WebSocket connection to 'wss://planka.test.com/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 400
p.doOpen @ websocket.js:124
i.open @ transport.js:84
l.open @ socket.js:250
l @ socket.js:122
l @ socket.js:28
d.open.d.connect @ manager.js:226
(anonymous) @ manager.js:540

This is what I get, indeed it has an error.

gamelaster commented 4 years ago

Very strange. Are you sure that you reloaded your config? Also, which nginx version do you have? This error happens when you don't have this code in your nginx location:

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
ghost commented 4 years ago

Very strange. Are you sure that you reloaded your config? Also, which nginx version do you have? This error happens when you don't have this code in your nginx location:

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

Pretty sure, I did alot of googling and many are certain that this will remove the error but not for me.

meltyshev commented 4 years ago

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).

ghost commented 4 years ago

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).

Perfect, it works right now! Thanks everyone for the help!

tricoos commented 3 years ago

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!

pluveto commented 2 years ago

HTTP works but Websocket not

websocket.js:124 

       WebSocket connection to 'ws://***/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=node&__sails_io_sdk_language=javascript&EIO=3&transport=websocket' failed: 
f.doOpen @ websocket.js:124
o.open @ transport.js:84
l.open @ socket.js:250
l @ socket.js:122
l @ socket.js:28
p.open.p.connect @ manager.js:226
p @ manager.js:69
p @ manager.js:37
c @ index.js:60
(anonymous) @ sails.io.js:884
(anonymous) @ sails.io.js:861
u._connect @ sails.io.js:850
Xe.CALL @ redux-saga-core.esm.js:524
(anonymous) @ redux-saga-core.esm.js:1203
f @ redux-saga-core.esm.js:1271
d @ redux-saga-core.esm.js:1161
c @ redux-saga-core.esm.js:1251
n @ io-6de156f3.js:165
c @ redux-saga-core.esm.js:1251
(anonymous) @ redux-saga-core.esm.js:592
Ue @ redux-saga-core.esm.js:56
Xe.FORK @ redux-saga-core.esm.js:584
(anonymous) @ redux-saga-core.esm.js:1203
f @ redux-saga-core.esm.js:1271
(anonymous) @ redux-saga-core.esm.js:673
Xe.ALL @ redux-saga-core.esm.js:672
(anonymous) @ redux-saga-core.esm.js:1203
f @ redux-saga-core.esm.js:1271
d @ redux-saga-core.esm.js:1161
pt @ redux-saga-core.esm.js:1108
Xe.CALL @ redux-saga-core.esm.js:533
(anonymous) @ redux-saga-core.esm.js:1203
f @ redux-saga-core.esm.js:1271
d @ redux-saga-core.esm.js:1161
c @ redux-saga-core.esm.js:1251
Xe.CALL @ redux-saga-core.esm.js:539
(anonymous) @ redux-saga-core.esm.js:1203
f @ redux-saga-core.esm.js:1271
d @ redux-saga-core.esm.js:1161
pt @ redux-saga-core.esm.js:1108
(anonymous) @ redux-saga-core.esm.js:1367
Ue @ redux-saga-core.esm.js:56
ht @ redux-saga-core.esm.js:1366
u.run @ redux-saga-core.esm.js:1423
(anonymous) @ store.js:28
(anonymous) @ index.js:10
(anonymous) @ index.js:10
Show 17 more frames
websocket.js:124 
gamelaster commented 2 years ago

@pluveto Please post your nginx site config.

pluveto commented 2 years ago

@gamelaster Exact same config as @tricoos 's but domain. Finally resolved by reinstall containers without changing nginx config. I guess may be caused by a strange state of the running nodejs process.

daniel-hiller commented 1 year ago

Sample NGIX configuration

https://docs.planka.cloud/docs/Configuration/webserver/NGINX