簡體   English   中英

重定向到https不起作用(和https本身不起作用)

[英]Redirect to https not working (and https itself not working)

我的目標是使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返回成功。

我收到相同的錯誤當我運行sudo netstat -tlnp | grep 443 tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 10031 / nginx

然后我發現這是該站點可用的服務器配置文件。 現在正在工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM