error:1035 connect() failed (111: Connection refused) while connecting to upstream, client: …217, server: .com, request: “POST /api/userLogin HTTP/1.1”, upstream: “http://.1:8443/userLogin”, host: “*.com”
1. Cause
The deployment of the project is on Tencent cloud server, http upgraded to https, using Tencent ssl certificate, Ali’s domain name, during the nginx.conf configuration process, there is a front-end to back-end send request failure problem. The following error occurs.
The nginx.conf configuration is as follows:
server{
#SSL The default access port number is 443
listen 443 ssl;
server_name domain;
default_type text/html;
ssl_certificate certificate file path (.crt/.pem);
ssl_certificate_key private key file path (.key);
ssl_session_timeout 5m;
# Please configure according to the following protocols
ssl_protocols TLSv1.2 TLSv1.3;
s#Please configure the encryption suite according to the following suite configuration, written following the openssl standard.
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location/{
root /usr/share/nginx/html/dist/;
try_files $uri $uri/ /index.html;
index index.html;
}
location /api/ {
default_type application/json;
proxy_pass http://localhost:8443/;
}
}
2. Solutions
Add a clause to the nginx.conf configuration: proxy_set_header Host $http_host;
server{
#SSL The default access port number is 443
listen 443 ssl;
server_name domain;
default_type text/html;
ssl_certificate certificate file path (.crt/.pem);
ssl_certificate_key private key file path (.key);
ssl_session_timeout 5m;
# Please configure according to the following protocols
ssl_protocols TLSv1.2 TLSv1.3;
s#Please configure the encryption suite according to the following suite configuration, written following the openssl standard.
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location/{
root /usr/share/nginx/html/dist/;
try_files $uri $uri/ /index.html;
index index.html;
}
location /api/ {
# nginx reverse proxy rewrites the host field attribute in the request header
proxy_set_header Host $http_host;
default_type application/json;
proxy_pass http://localhost:8443/;
}
}
Read More:
- Nginx reports 502 error, log connect() failed (111: Connection refused) while connecting to upstream. A personal effective solution
- 【wget failed】Connecting to 127.0.0.1:7890… failed: Connection refused.
- curl: (7) Failed connect to localhost:9200; Connection refused
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
- 【MongoDB】 Failed to connect to 127.0.0.1:27017, reason: Connection refused
- Running Django manager.py report errors Error:111 connecting to 127.0.0.1:6379.connection refused
- Failed to connect to 17.0.0.1 port 1080: Connection refused
- samba Error NT_STATUS_CONNECTION_REFUSED Failed to connect with SMB1 — no workgroup available
- 【Synergy】Error:failed to connect to server:Connection was refused
- How to Fix java.net.ConnectException: Connection refused: connect
- failed to connect to ‘192.168.199.143:5555‘: Connection refused
- Solve the MAC terminal download error curl: (7) failed to connect to raw.githubusercontent.com port 443: Connection refused
- error:Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused;error:couldn‘t ….
- solve java.net.ConnectException : Connection refused:connect report errors
- (20200916 Solved)Docker||redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused
- Java connection SQL error, network error IO Exception:Connection refused :connect
- About JMH running ERROR: transport error 202: connect failed: Connection refused ERROR
- Zookeeper connection timeout problem, and refused to connect to solve the problem
- JDBC connect to Sql Server to connect to the database–The TCP/IP connection to the host localhost, port 1433 has failed
- Failed to load resource: net::ERR_CONNECTION_REFUSED