[SOLVED] No mongoDB connection when running nginx



  • When running nginx my site will load fine, but it won't pull things or save to the database. I'm guessing it's a websocket problem.

    Here's my nodebb config.json (Omitting the secure details):

    {
    "base_url": "http://test.mysite.com",
    "port": "4567",
    "secret": "some_secret_characters_here",
    "bind_address": "0.0.0.0",
    "database": "mongo",
    "mongo": {
    "host": "127.0.0.1",
    "port": "27017",
    "username": "youthought",
    "password": "youknew",
    "database": "mysiteTest"
    },
    "bcrypt_rounds": 12,
    "upload_path": "/public/uploads",
    "use_port": false,
    "relative_path": ""
    }

    I have a subdomain called test for this particular instance of nodebb.

    Here is my nginx.conf:

    worker_processes 2;
    worker_rlimit_nofile 10240; # worker_connections * 4
    events {
    multi_accept on;
    worker_connections 5120;
    use epoll;
    }
    http {
    charset utf-8;
    client_body_timeout 65;
    client_header_timeout 65;
    client_max_body_size 10m;
    default_type application/octet-stream;
    keepalive_timeout 20;
    reset_timedout_connection on;
    send_timeout 65;
    server_tokens off;
    sendfile on;
    server_names_hash_bucket_size 64;
    tcp_nodelay off;
    tcp_nopush on;
    include sites-enabled/test.mysite.com;
    }

    Here is the sites-enabled/test.mysite.com config:

    server {

    listen 80;

    server_name test.mysite.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";

    }

    }

    Also, the site itself is held at /var/www/mysite.test so not sure if it makes a difference whether the directory is called test.mysite.com or not...I'm assuming I can name the directory whatever I want without it making a difference.

    Here's my hosts file:

    127.0.0.1 localhost
    127.0.0.1 mysite.com
    127.0.0.1 test.mysite.com

    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters

    So, if I have nodebb and nginx running I can go to test.mysite.com (port 80) and it will load just fine, but it won't pull anything from the database. When I log in it redirects me to a {login successful} screen, then once I navigate to the admin area I can't save any changes. However, I can go to test.mysite.com:4567 and everything works just fine. This confuses me...

    What I'm trying to achieve is having everything working on port 80 while not allowing traffic to directly connect to 4567.

    I haven't used nginx much, so it's all new to me. Any help or suggestions would be appreciated.

    I love you...



  • I figured this out finally...I had nginx v1.2 which is what's in the default debian 7 repo. Had to add a new key and some new sources from here:

    Now on nginx v1.6.2 and it seems to be running fine. From what I read there was no websocket support in nginx <1.3



Suggested Topics

  • 33
  • 6
  • 1
  • 52
  • 4
| |