我只想将特定的域指向server:port,然后使用nginx配置进行配置,但显示502错误的网关。
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
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;
keepalive_timeout 65;
server {
listen 80;
server_name cilpboard.com;
location / {
proxy_pass http://127.0.0.1:8081;
}
}
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html/;
index index.html index.htm;
}
location = /50x.html {
root html;
}
error_page 500 502 503 504 /50x.html;
}
}
它显示错误消息:
nginx_1 | 2019/10/29 13:42:31 [error] 7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 136.228.142.68, server: cilpboard.com, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8081/", host: "cilpboard.com"
nginx_1 | 136.228.142.68 - - [29/Oct/2019:13:42:31 +0000] "GET / HTTP/1.1" 502 559 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36" "-"
我将proxy_pass修改为http://localhost:8081,如果我将其更改为真正的ipv4 ip“ http:/45.82.79.214:8081"
,它们仍然无法正常工作。
有什么问题吗?