[英]Redirect to https not working (and https itself not working)
My goals are to get https to work, and then get the http to https redirections, and the non-www to www redirections to work. 我的目标是使https工作,然后将http重定向到https,将非www重定向到www进行工作。
Nginx.conf looks like: 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 looks like: 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
is successful, however the website's https isn't working, nor the redirects. service nginx reload
成功,但是网站的https无法正常工作,也没有重定向。 http is working as before. http像以前一样工作。
nginx -t returns successful. nginx -t返回成功。
I am getting the same error Its show me like this when i run sudo netstat -tlnp | 我收到相同的错误当我运行sudo netstat -tlnp | grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10031/nginx
grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10031 / nginx
Then i found it was the site available server config file was the problem. 然后我发现这是该站点可用的服务器配置文件。 Its working now.
现在正在工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.