节点快车线路远程服务器上本地但不是工作
我有一个节点的应用程序,在本地工作,并使用快速路由。我试图设置此使用their guide数字海洋。我可以看到我的应用程序的主页,当我浏览到/,但我不能访问任何的内页。
为了调试我停止通过PM2运行的应用程序,只需通过调用端“节点app.js”,这样我可以看到控制台日志消息跑了。
我把测试快递航线评论:
app.get('/', function (req, res) {
console.log('/ route requested');
if (req.isAuthenticated()) {
res.render('home',
{
user: req.user
});
} else {
res.render('home',
{
user: null
});
}
});
app.get('/signup', function (req, res) {
console.log('/signup route requested');
res.render('signup');
});
当我请求打印“/”控制台日志消息。然而试图访问“/注册”没有什么是显示在终端。我被带到一个默认的404页(nginx的/ 1.10.0(Ubuntu的)。
我曾试图建立的Nginx作为反向代理detailed here。下面是等/ nginx的/网站可用/默认我的nginx的配置
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See:
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See:
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:2000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
另外,索引页是不是从我的公共目录加载资源,如样式。
我将不胜感激试图让快递线路和资源,在远程服务器上加载任何帮助。请让我知道如果他们的是更多的信息,这将是对调试很有帮助。
回答如下:从您发布的nginx的配置来看,似乎你正在使用的try_files
指令一起proxy_pass
这可能是导致竞争条件。 nginx的可能正试图为你的URI的文件,它几乎肯定不能做的。
从Location
指令删除以下行应该做的伎俩:
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
节点快车线路远程服务器上本地但不是工作
我有一个节点的应用程序,在本地工作,并使用快速路由。我试图设置此使用their guide数字海洋。我可以看到我的应用程序的主页,当我浏览到/,但我不能访问任何的内页。
为了调试我停止通过PM2运行的应用程序,只需通过调用端“节点app.js”,这样我可以看到控制台日志消息跑了。
我把测试快递航线评论:
app.get('/', function (req, res) {
console.log('/ route requested');
if (req.isAuthenticated()) {
res.render('home',
{
user: req.user
});
} else {
res.render('home',
{
user: null
});
}
});
app.get('/signup', function (req, res) {
console.log('/signup route requested');
res.render('signup');
});
当我请求打印“/”控制台日志消息。然而试图访问“/注册”没有什么是显示在终端。我被带到一个默认的404页(nginx的/ 1.10.0(Ubuntu的)。
我曾试图建立的Nginx作为反向代理detailed here。下面是等/ nginx的/网站可用/默认我的nginx的配置
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See:
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See:
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:2000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
另外,索引页是不是从我的公共目录加载资源,如样式。
我将不胜感激试图让快递线路和资源,在远程服务器上加载任何帮助。请让我知道如果他们的是更多的信息,这将是对调试很有帮助。
回答如下:从您发布的nginx的配置来看,似乎你正在使用的try_files
指令一起proxy_pass
这可能是导致竞争条件。 nginx的可能正试图为你的URI的文件,它几乎肯定不能做的。
从Location
指令删除以下行应该做的伎俩:
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;