boomzillawtf / nodebb-plugin-youtube-embed

Embed Youtube Videos on your NodeBB Forum
BSD 2-Clause "Simplified" License
10 stars 2 forks source link

Crash if installed on subpath #10

Open kylechine opened 6 years ago

kylechine commented 6 years ago

Hello boomzillawtf,

Thanks for your plugin, it's very helpful. I probably found a bug:

In short: it cause entire forum return 502 error, if installed on subpath, like https://www.example.com/en-US

Environment:

Debian 9 NodeBB 1.8.2, NodeJS 8.11.1 Nginx 1.10.3 MongoDB 3.2.11

NodeBB listen localhost and port 4567. Nginx was used as rev-proxy to NodeBB.

It was worked perfectly fine when I installed it at root path for my system. But later I decided to move my forum to multiple languages, so the structure was:

forum.example.com/en forum.example.com/zh ...

It caused entire forum return 502 error.

This is my config.json:

{
    "url": "https://forum.unbelievable.sale/zh-Hans",
    "secret": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
    "database": "mongo",
    "mongo": {
        "host": "127.0.0.1",
        "port": "27017",
        "username": "xxxxxxxxxxxxxxx",
        "password": "xxxxxxxxxxxxxxx",
        "database": "xxxxxxxxxxxxxxxx",
        "uri": ""
    },
    "type": "literal",
    "bind_address": "127.0.0.1",
    "port": "4567"
}

And config of Nginx

server {
    listen 443 ssl;

    server_name forum.unbelievable.sale;

    ssl_certificate /etc/ssl/certs/unbelievable_sale.crt.all;
    ssl_certificate_key /etc/ssl/private/unbelievable_sale.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers 'AES128+EECDH:AES128+EDH';
    ssl_prefer_server_ciphers on;

    location / {
        return 307 https://$host/zh-Hans$request_uri;
    }

    location /zh-Hans {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:4567;
        proxy_redirect off;

        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

Hope it may help. Thank you!

kylechine commented 6 years ago

I've downgraded my NodeBB to 1.7.5, then this plugin works perfectly fine.

boomzillawtf commented 6 years ago

I just tried it out with NodeBB 1.8.2 and it was working locally. Was there a stack trace or anything associated with the 502 errors?