我的目标是让https工作,然后将http转换为https重定向,并将非www转换为www重定向。
Nginx.conf看起来像:
http {
include mime.types;
default_type application/octet-stream;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include site.conf;
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
}
}
site.conf看起来像:
upstream site_local {
server 127.0.0.1:9090 max_fails=3 fail_timeout=20s;
}
server {
listen 80;
server_name site.com;
return 301 https://www.site.com$request_uri;
}
server {
listen 80;
server_name www.site.com;
return 301 https://www.site.com$request_uri;
}
server {
listen 443;
server_name www.site.com;
set $app_root /home/site/site-web-node/public;
ssl on;
ssl_certificate /etc/ssl/SSL.crt;
ssl_certificate_key /etc/ssl/site.key;
location / {
proxy_pass https://site_local;
client_max_body_size 10m;
client_body_buffer_size 128k;
}
location ~ /(app|lang|js) {
root $app_root;
}
}
service nginx reload
成功,但网站的https无法正常运行,也无法重定向。 http像以前一样工作。
nginx -t返回成功。
答案 0 :(得分:0)
我收到同样的错误 当我运行sudo netstat -tlnp |时,它就像这样给我看grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10031 / nginx
然后我发现它是网站可用的服务器配置文件是问题。它现在正在工作。