Serving up static content with nginx with nodebb running from subfolder.

  • I have nginx proxying to nodebb, from a /forum/ location.

    I wanted to serve up static contents with nginx - the example here - assumes you have the forum running off the root. If running from a subfolder, it can be simplified to this (the public folder is tried first, followed by the proxy if no file exists).

    Here's my config using nginx to serve up the static content (just the locations/configs for nodebb included, I have a wordpress site running of the htdocs root)

    upstream io_nodes {
        server; # upstream nodebb servers here
    server {
        listen 443 default_server ssl;
        listen [::]:443 default_server ssl;
        root /webroot/of/site;
        index index.html index.php;
        location /forum {
            alias /path/to/nodebb/public;
            try_files $uri @nodebb;
        location @nodebb {
            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_redirect off;
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://io_nodes;

Suggested Topics

  • 14
  • 2
  • 1
  • 15
  • 25
| | |

© 2014 – 2022 NodeBB, Inc. — Made in Canada.