gpt4 book ai didi

ubuntu - ERR_CONNECTION_REFUSED NGINX 代理反向

转载 作者:行者123 更新时间:2023-12-04 19:27:33 25 4
gpt4 key购买 nike

我很难解决几天内无法解决的问题。
问题是 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:

最佳答案

error CONNECTION_REFUSE D 适用于服务未在您请求的特定端口上运行的情况。使用命令ss -nltup获取正在监听的所有可用端口的列表。我相信该服务未在端口 5000 上运行。

关于ubuntu - ERR_CONNECTION_REFUSED NGINX 代理反向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69681915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com