我看了这个问题,但没有任何帮助。我正在尝试将其配置localhost:3000
为代理到端口 80。这是我的 nginx 配置(位于sites-enabled
和sites-available
):
server {
listen 0.0.0.0:80;
server_name fit-forms;
access_log /var/log/nginx/fit-forms.log;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header HOST $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:3000;
proxy_redirect off;
}
}
我Cannot GET /
在访问 IP 时得到(这是在 DigitalOean 上)。没有显示任何静态文件。这是我的快速代码:
var express = require('express'),
livereload = require('connect-livereload'),
config = require('./config'),
app = express(),
env = app.get('env'),
port = process.env.PORT || config.serverPort || 3000;
if (env === 'development') {
app.use(livereload());
app.use(express.logger('dev'));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
}
app.use(express.compress());
app.use(express.urlencoded());
app.use(express.json());
app.use(express.static(__dirname + '/public'));
app.listen(port);
console.log('Express server (' + env + ') running on port ' + port);
我假设我的 nginx 配置缺少..