[英]ERR_CONNECTION_REFUSED NGINX PROXY REVERSE
我在解決幾天內無法解決的問題時遇到了困難。
問題是ERR_CONNECTION_REFUSED的錯誤。
我正在嘗試使用子域通過反向代理訪問 api。
我正在使用 Ubuntu。
這是配置:
default:
server {
listen 80;
listen [::]:8080;
root /var/www/servicos.siteabc.org;
server_name servicos.siteabc.org;
#server_name _ ;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location / {
proxy_redirect off;
proxy_set_header host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-forward-for $proxy_add_x_forwarded_for;
proxy_pass http://localhost:5000;
}
}
servicos.siteabc.org:
[Unit]
Description=Example .NET Web API App running on Ubuntu
[Service]
WorkingDirectory=/var/www/servicos.siteabc.org
ExecStart=/usr/bin/dotnet /var/www/servicos.siteabc.org/TDWebApi.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
#User=root;
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
client_max_body_size 10M;
}
顯然我的服務運行正常:
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-22 17:32:00 UTC; 1h 21min ago
Docs: man:nginx(8)
Process: 275411 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS)
Main PID: 273065 (nginx)
Tasks: 3 (limit: 614)
Memory: 10.3M
CGroup: /system.slice/nginx.service
├─273065 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─275412 nginx: worker process
└─275413 nginx: worker process
Oct 22 17:32:00 siteabc.org systemd[1]: Starting A high performance web server and a reverse proxy server...
Oct 22 17:32:00 siteabc.org systemd[1]: Started A high performance web server and a reverse proxy server.
Oct 22 18:21:19 siteabc.org systemd[1]: Reloading A high performance web server and a reverse proxy server.
Oct 22 18:21:19 siteabc.org systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Oct 22 18:23:21 siteabc.org systemd[1]: Reloading A high performance web server and a reverse proxy server.
Oct 22 18:23:21 siteabc.org systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Oct 22 18:25:44 siteabc.org systemd[1]: Reloading A high performance web server and a reverse proxy server.
Oct 22 18:25:44 siteabc.org systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Oct 22 18:30:51 siteabc.org systemd[1]: Reloading A high performance web server and a reverse proxy server.
Oct 22 18:30:51 siteabc.org systemd[1]: Reloaded A high performance web server and a reverse proxy server.
root@siteabc:/var/www# sudo systemctl status servicostreed.service
● servicostreed.service - Example .NET Web API App running on Ubuntu
Loaded: loaded (/etc/systemd/system/servicostreed.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-10-22 16:59:37 UTC; 1h 53min ago
Main PID: 271237 (dotnet)
Tasks: 16 (limit: 614)
Memory: 34.9M
CGroup: /system.slice/servicostreed.service
└─271237 /usr/bin/dotnet /var/www/servicos.siteabc.org/TDWebApi.dll
Oct 22 16:59:37 siteabc.org systemd[1]: Started Example .NET Web API App running on Ubuntu.
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: info: Microsoft.Hosting.Lifetime[0]
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: Now listening on: http://localhost:5000
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: info: Microsoft.Hosting.Lifetime[0]
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: Application started. Press Ctrl+C to shut down.
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: info: Microsoft.Hosting.Lifetime[0]
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: Hosting environment: Production
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: info: Microsoft.Hosting.Lifetime[0]
Oct 22 16:59:39 siteabc.org dotnet-example[271237]: Content root path:
錯誤 CONNECTION_REFUSED 用於服務未在您請求的特定端口上運行的情況。 使用命令“ss -nltup”獲取正在偵聽的所有可用端口的列表。 我相信該服務沒有在端口 5000 上運行。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.