NGINX PROXY

General Discussion
  • I currently have nodebb running on webexample.com:4567 and I'm trying to wrap my head around on being able to run it as

    community.webexample.com

    or even

    webexample.com without the port.

    Right now if I go to webexample.com, I get

    Welcome to nginx on Debian!
    
    If you see this page, the nginx web server is successfully installed and working on Debian. Further configuration is required.
    
    For online documentation and support please refer to nginx.org
    
    Please use the reportbug tool to report bugs in the nginx package with Debian. However, check existing bug reports before reporting a new bug.
    
    Thank you for using debian and nginx.
    

    I can visit the page at :4567 still.

    Here's config.json

    {
        "base_url": "http://127.0.0.1",
        "port": "4567",
        "secret": "xxxxxxxxxx",
        "bind_address": "xxxxxxxxx",
        "database": "redis",
        "redis": {
            "host": "127.0.0.1",
            "port": "6379",
            "password": "xxxxxxxxxx",
            "database": "0"
        },
        "bcrypt_rounds": 12,
        "upload_path": "/public/uploads",
        "use_port": false,
        "relative_path": ""
    }
    

    Sites-Enabled:

    server {
        listen 80;
    
        server_name community.webexample.com;
    
        location / {
            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_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";
        }
    }
    

    What have I overlooked? Nginx is 1.6.2

  • I'm not an expert since I don't run a live NodeBB, so I may be wrong...

    But as far I understand bind_address within config.json has to be sth. like 127.0.0.1 (the IP you want NodeBB to run at, so localhost most commonly since you pass to http://127.0.0.1:4567 using nginx).
    Also base_url would be http://community.webexample.com in your case.

  • as frissdiegurke said: you need to bind to localhost -> 127.0.0.1

  • Most OSes have localhost pointing to 127.0.0.1, but that's a good thing to check. As @frissdiegurke mentions, your base_url should be http://community.webexample.com.

    I'm not sure if Debian uses sites-enabled, but you can configure it to if nginx does not already do that:

    • Open up your nginx.conf file. It may be located at /etc/nginx, but Debian might not place it there
    • Near the bottom, it should have a line that reads something like: include /etc/nginx/sites-enabled/*; (though again, the path may be different)
    • Your nginx configuration file for NodeBB should live in that directory, otherwise it will not be parsed
    • Also, don't forget to test the nginx config after changes (as root, nginx -t), and reload your config (service nginx reload)
  • @frissdiegurke said:

    I'm not an expert since I don't run a live NodeBB, so I may be wrong...

    But as far I understand bind_address within config.json has to be sth. like 127.0.0.1 (the IP you want NodeBB to run at, so localhost most commonly since you pass to http://127.0.0.1:4567 using nginx).
    Also base_url would be http://community.webexample.com in your case.

    This solved it!

    @julian said:

    Most OSes have localhost pointing to 127.0.0.1, but that's a good thing to check. As @frissdiegurke mentions, your base_url should be http://community.webexample.com.

    I'm not sure if Debian uses sites-enabled, but you can configure it to if nginx does not already do that:

    • Open up your nginx.conf file. It may be located at /etc/nginx, but Debian might not place it there
    • Near the bottom, it should have a line that reads something like: include /etc/nginx/sites-enabled/*; (though again, the path may be different)
    • Your nginx configuration file for NodeBB should live in that directory, otherwise it will not be parsed
    • Also, don't forget to test the nginx config after changes (as root, nginx -t), and reload your config (service nginx reload)

    I'm actually running Ubuntu, but it states Debian.

    I've run into another issue with sub domains (mostly because I don't understand them)

    
    {
        "base_url": "http://community.webexample.com",
        "port": "4567",
        "secret": "xxxxxxxxx",
        "bind_address": "0.0.0.0",
        "database": "redis",
        "redis": {
            "host": "127.0.0.1",
            "port": "6379",
            "password": "xxxxxxxxx",
            "database": "0"
        },
        "bcrypt_rounds": 12,
        "upload_path": "/public/uploads",
        "use_port": false,
        "relative_path": ""
    }
    
    server {
        listen 80;
    
        server_name community.webexample.com;
    
        location / {
            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_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";
        }
    }
    

    So I can get it to load fine via the www.webexample.com domain, but I haven't been able to successfully move it to the subdomain community

    I created a subdomain called community in godaddy under Subdomain forwarding.

    Subdomain: community
    Forward To: http://community.webexample.com
    Type: Forward Only

    What am I doing wrong now?

  • @Adrian-Kaepernick you'll need to set an A record to your server, not a CNAME

  • @julian said:

    @Adrian-Kaepernick you'll need to set an A record to your server, not a CNAME

    Yup. This was the issue.

    Thank you!

  • Glad to hear it was resolved 😄


Suggested Topics


| | | |