我已经尝试了两天来让我的服务器运行......我想我已经有 30 种不同的 nginx 配置,并尝试了不同的端口和所有内容。我现在很沮丧,因为做设置 nginx + 节点服务器教程的人都没有提到错误,一切似乎都很简单,但显然不是......
我让nginx服务器以其标准配置运行:
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a TLS enabled server.
#
# server {
# listen 443 ssl http2 default_server;
# listen [::]:443 ssl http2 default_server;
# server_name _;
# root /usr/share/nginx/html;
#
# ssl_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
哪些服务器我成功地为我提供了默认测试页面...
这是我的服务器.js我通过 pm2 运行:
var express = require('express'),
path = require('path'),
app = express();
//set the port
app.set('port', 3000);
//get node files i need
app.use('/fa', express.static(__dirname + '/node_modules/@fortawesome/fontawesome-free/'));
//tell express that we want to use the www folder
//for our static assets
app.use(express.static(path.join(__dirname, 'www')));
// Listen for requests
var server = app.listen(app.get('port'), function () {
console.log('The server is running on http://localhost:' + app.get('port'));
});
所以我测试的最后一个配置是原始的,只是位置块替换为:
location / {
proxy_pass http://localhost:3000;
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;
}
但我也测试了非常简单的 confs,例如:
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name _;
location / {
proxy_pass http://localhost:3000;
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;
}
}
}
我只是不知道出了什么问题...
通过 curl http://localhost:8080 我正在接收我的 html,但没有收到我给定的服务器 IP......
Netstat给了我这个:
netstat -tulpn | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:*
LISTEN 14841/nginx: master
tcp6 0 0 :::80 :::*
LISTEN 14841/nginx: master
netstat -tulpn | grep :3000
tcp 0 0 127.0.0.1:3000 0.0.0.0:*
LISTEN 14375/node /home/no
顺便说一句:我通过 systemctl 和 pm2 作为非 root 用户通过 pm2 启动服务器运行 fedora 30 和 nginx.js。 我也使用 UFW 和禁用的枞木,但 WWW 在 ufw 中是允许的......
我非常感谢你们能给我的所有帮助和建议。
我根本不知道该怎么办:(...
好的,我现在想通了。这是一个 SELinux 规则错误。拒绝我通过http连接到我的服务器。
setsebool httpd_can_network_connect on -P
永久修复它。 这篇文章回答了我的问题:
(13:权限被拒绝)连接到上游时:[nginx]
问候 乔希。
如果你愿意,你可以签出页面,警告其18+内容:D 我知道IO设备存在画布错误,但在那里不起作用。 而且由于资产繁重,我不建议您使用有限的数据计划(大约 70Mb 的 3D 资产)。如果它是否有效,请与我联系(它只是更大:)的实验)。 IP 是: 140.82.47.236