openresty(Nginx) 301重定向域名 http访问强制使用https

1 访问http

2  修改配置访问

server {
    listen       80;

    server_name  example.cn;
    return 301 https://$server_name$request_uri;


    access_log  /data/logs/czgzzfjgsup_access.log  access;
    error_log  /data/logs/czgzzfjg_error.log  error;

#

    location / {
 
       root  /usr/local/openresty/nginx/html/;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

3 在访问http会强制跳转到https

 

#全站统一强制使用https,启用严格传输安全,在一年内,任何使用HTTP的请求都将被浏览器自动转换为HTTPS请求
vim nginx.conf
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload" always;

 

相关推荐

  1. 使用 Nginx 将 HTTP 定向HTTPS

    2024-06-18 07:08:03       51 阅读
  2. http请求定向

    2024-06-18 07:08:03       63 阅读
  3. Apace配置+http定向https

    2024-06-18 07:08:03       78 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-18 07:08:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-18 07:08:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-06-18 07:08:03       82 阅读
  4. Python语言-面向对象

    2024-06-18 07:08:03       91 阅读

热门阅读

  1. 【Homebrew】包管理器清理软件包,释放mac空间

    2024-06-18 07:08:03       44 阅读
  2. redis击穿问题使用锁实现方案

    2024-06-18 07:08:03       33 阅读
  3. ZSH 配置

    2024-06-18 07:08:03       32 阅读
  4. supersocket的socket层源码解析

    2024-06-18 07:08:03       33 阅读
  5. codeArts Snap:辅助你的编程神器

    2024-06-18 07:08:03       31 阅读
  6. 机器学习中的神经网络重难点!纯干货(上篇)

    2024-06-18 07:08:03       34 阅读
  7. LeetCode 619, 58, 24

    2024-06-18 07:08:03       43 阅读