无法在没有端口的子域上运行Ghost博客

时间:2014-01-26 22:09:58

标签: apache nginx ghost-blog

我是nginx,Ghost和管理服务器的新手,无法指定如何在不指定端口:2368

的情况下运行ghost

http://blog.ingledow.co.uk:2368有效,但http://blog.ingledow.co.uk没有。

我的数字海洋小滴上有两个站点,/etc/nginx/sites-enabled/中有两个.conf文件。这些是ghost.confingledow.co.uk

顺便说一下,目录/etc/nginx/conf.d/是空的。

Ghost的config.js

// ### Production
    // When running Ghost in the wild, use the production environment
    // Configure your URL and mail settings here
    production: {
        url: 'http://blog.ingledow.co.uk',
        mail: {},
        database: {
            client: 'sqlite3',
            connection: {
                filename: path.join(__dirname, '/content/data/ghost.db')
            },
            debug: false
        },
        server: {
            // Host to be passed to node's `net.Server#listen()`
            host: '146.185.179.133',
            // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
            port: '2368'
        }
    }

/etc/nginx/nginx.conf

http {
    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

/etc/nginx/sites-enabled/ghost.conf

server {
    listen 80;
    server_name blog.ingledow.co.uk;

    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
        proxy_buffering off;
    }
}

2 个答案:

答案 0 :(得分:2)

配置似乎没问题,但我认为config.js文件中的主机地址应为127.0.0.1

server: {
        // Host to be passed to node's `net.Server#listen()`
        host: '127.0.0.1',
        // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
        port: '2368'
    }

答案 1 :(得分:0)

我遇到了类似的问题,原因是我最初更改了Ghost config.js文件以使用我服务器的IP地址和域名,因此我可以通过IP:2368和域名来访问它。一旦工作,我想设置nginx监听端口80并重定向到端口2368.但是,一旦你有nginx设置,它将侦听服务器的IP端口80,所以你会想要重定向到Ghost,这应该设置为localhost地址127.0.0.1,而不是服务器的IP,端口应为2368(如果尚未)。冰川