我在端口3000上运行了两个NodeJS应用程序,在NGINX后面运行了3001,所以我通过端口80在NGINX上完成了代理,运行在3000和3001端口上运行的NodeJS应用程序。它运行没有问题,我可以通过端口80上的DNS从公共网络访问应用程序,但是当我在NGINX端口443上配置SSL时它在端口上出现错误 The plain HTTP request was sent to HTTPS port with 400 status
80仍然可以访问,没有问题。
NGINX CONFIGURATION
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
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 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
gzip on;
upstream app_nodejs {
server 127.0.0.1:3000;
}
upstream api_nodejs {
server 127.0.0.1:3001;
}
server {
listen 80;
listen 443 ssl;
ssl_certificate /home/foo/htdocs/SSLs/foo.crt;
ssl_certificate_key /home/foo/htdocs/SSLs/foo.key;
ssl_protocols SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_nodejs;
proxy_redirect off;
}
location /api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://api_nodejs;
proxy_redirect off;
}
}
}
端口443的卷曲响应(curl 127.0.0.1:443
)
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx/1.6.3</center>
</body>
</html>
浏览器超时。