NodeBB与Nginx - “此网页有一个重定向循环”

时间:2014-10-22 08:53:17

标签: nginx nodebb

我正在尝试在xxx.xxx.xxx.xxx/nodebb设置NodeBB。我有Nginx和NodeBB的以下设置:

/etc/nginx/conf.d/nodebb.conf

server {
    listen 80;

    server_name localhost;

    location /nodebb/ {
        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";
    }
}

/usr/share/nginx/nodebb/config.json

{
    "base_url": "http://`xxx.xxx.xxx.xxx",
    "port": "4567",
    "secret": "xxxxxx-xxxxxxxxxxx-xxxxxx-xxxxx",
    "bind_address": "0.0.0.0",
    "database": "mongo",
    "mongo": {
        "host": "127.0.0.1",
        "port": "27017",
        "username": "xxxxxxxx",
        "password": "xxxxxxxxxxx",
        "database": "xxxxxxx"
    },
    "bcrypt_rounds": 12,
    "upload_path": "/public/uploads",
    "use_port": false,
    "relative_path": "/nodebb"
}

当我导航到xxx.xxx.xxx.xxx/nodebb时,我会被重定向到xxx.xxx.xxx.xxx/nodebb/404,并显示浏览器错误消息This web page has a redirect loop。我有什么想法吗?

编辑:只是说如果我导航到http://xxx.xxx.xxx.xxx:4567/nodebb/ - 它运作正常

2 个答案:

答案 0 :(得分:0)

将您的服务器名称设置为与base_url相同,而不是localhost。

答案 1 :(得分:0)

将/etc/nginx/conf.d/nodebb.conf中的server_name设置为yourdomain.com,将/ usr / share / nginx / nodebb中的base_url设置为http://127.0.0.1 /config.json。

  

如果您这样做,您将无法在http://yourdomain.com:4567上打开nodebb网站,而是在http://yourdomain.comhttp://yourdomain.com:80(这是默认端口)上打开。