Nginx 502 Bad Gateway and NodeBB subdomain installation

Bug Reports
  • I'm posting this under Bug Reports knowing that it might not have anything to do with NodeBB itself. Most likely, it's an Nginx configuration issue.

    And this is a continuation of Testing Subfolder Installation and Encountered Uncaught Exception: meta is not defined.

    Ok, so I've been trying to get a production installation of NodeBB running on a WP site powered by Nginx (1.4.6), Varnish and php-fpm. This should be the easiest thing to configure, but for some reason, it's not working on my site, even though I can access NodeBB without using Nginx proxy. This attempt is to run NodeBB from forum.mysite.com, after failing to run it from a subfolder. The error from both attempts is:

    [error] 9921#0: *148 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: forum.mysite.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:4567/", host: "forum.mysite.com"
    

    The connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: error is the same one I get when I attempt to access NodeBB from a subfolder on the same server, so this is not likely a DNS issue. Btw, I can access another WP site from a subdomain on the same server.

    The Nginx config for /sites-available/forum.mysite.com is:

    NOTE: Nginx is listening on 8080, while Varnish is listening on 80.

    #
    server {
        server_name forum.mysite.com www.forum.site.com;
        listen 8080;
    
    ## Settings for proxying Node.JS forum installation.
            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";
        }
    }
    

    And NodeBB's config.json is:

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

    I have the feeling that there's s minor configuration issue that's stopping the proxy-ing not to work correctly. Need anotehr pair of eyes on this forum to help me figure out what the node is going on.

  • @planner Could it be that nginx is attempting to use php-fpm to parse the page, but can't find an index.php, hence errors out?

  • @julian

    But there's nothing in the Nginx config for the forum that should trigger php-fpm. But even when I have settings for server root in there, the error is still the same.

    But if Nginx is attempting to use php-fpm, which should happen in this case, what's the solution? I can't possible disable php-fpm because WP needs it.

    It's a very curious thing because I've seen cases where Ghost is installed in a subdomain and even a subfolder of a WP site successfully.

    Right now, I am hitting blank.

  • @julian

    The other thing is php-fpm is listening via a Unix socket, while NodeBB is listening via a port. I'm just thinking out loud, hoping that something might click.

  • @julian

    I think I've got something. Not sure if that's the primary issue here, but it warrants attention.

    On my local installation, the output of an nmap scan shows that port 4567 is open:

    nmap localhost
    
    Starting Nmap 6.00 ( http://nmap.org ) at 2014-03-19 16:04 CDT
    Nmap scan report for localhost (127.0.0.1)
    Host is up (0.00019s latency).
    Not shown: 994 closed ports
    PORT     STATE SERVICE
    22/tcp   open  ssh
    80/tcp   open  http
    3306/tcp open  mysql
    4567/tcp open  tram
    5222/tcp open  xmpp-client
    5269/tcp open  xmpp-server
    

    And the output of netstat also shows the same port active.

    netstat |grep 4567
    
    tcp        0      0 localhost:46785         localhost:4567          TIME_WAIT  
    tcp        0      0 localhost:4567          localhost:47788         ESTABLISHED
    tcp        0      0 localhost:47788         localhost:4567          ESTABLISHED
    tcp        0      0 localhost:46783         localhost:4567          TIME_WAIT  
    tcp        0      0 localhost:4567          localhost:46752         CLOSE_WAIT 
    tcp        0      0 localhost:46784         localhost:4567          TIME_WAIT 
    

    However, the outputs of both commands on the main server doesn't show port 4567. And I can't even access the site by appending the port number to the domain.

    Now, why would the port not be open, even after running forever start app.js?

    Any clues?

  • Replied in the other topic 🙂


Suggested Topics


| | | |