如何在nginx

时间:2019-03-13 23:20:09

标签: nginx nginx-config

如何在nginx上强制http://example.comhttps://example.com

这是我当前的配置,仅当键入example.com并按指定重定向到https时,它才起作用,但是如果我使用显式方案http http://example.com键入,则不重定向到https。

server {
  listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

  server_name _;
  return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate     /etc/nginx/ssl/example.com.crt;
    ssl_certificate_key /etc/nginx/ssl/example.com.key;

    ...

}

0 个答案:

没有答案
相关问题