nginx安装数字证书支持http跳转到https

2021-01-04 16:29

阅读:504

标签:ati   cli   crt   code   $1   client   dex   ssl   cert   

server {
  listen 80;
  server_name localhost;
  rewrite ^(.*)$ https://$host$1 permanent;
}
server {
  listen 443 ssl;
  server_name localhost;
  proxy_buffering on;
  proxy_buffer_size 5120k;
  proxy_buffers 100 5120k;
  proxy_busy_buffers_size 5120k;
  client_max_body_size 10m;

  ssl_certificate D://nginx-1.18.0//ssl//4961490__xxxx.pem; # 这个是证书的crt文件所在目录
  ssl_certificate_key D://work//Learning/nginx-1.18.0//ssl//4961490__xxxx.key; # 这个是证书key文件所在目录
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;

  #charset koi8-r;
  #access_log logs/host.access.log main;


  #location / {
  # root $root;
  # index index.html index.htm;
  #}

  location / {
    add_header ‘Access-Control-Allow-Origin‘ ‘http://localhost‘;    
    if ($http_user_agent ~* ‘(Android|webOS|iPhone|iPod|BlackBerry)‘) {
      rewrite ^.+ https://191.168.3.74/mobile;
    }
    proxy_pass http://localhost:8080;
    proxy_redirect default;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }    


  location /mobile {
    add_header ‘Access-Control-Allow-Origin‘ ‘http://localhost‘;
    proxy_pass http://localhost:8080;
    proxy_redirect default;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }    

  location /api {
    add_header ‘Access-Control-Allow-Origin‘ ‘http://localhost‘;
    proxy_pass http://localhost:8081;
    proxy_redirect default;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location /file {
    add_header ‘Access-Control-Allow-Origin‘ ‘http://localhost‘;
    proxy_pass http://localhost:8082;
    proxy_redirect default;
    proxy_set_header Host $host;
    proxy_set_header X-Real-Ip $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

}

 

nginx安装数字证书支持http跳转到https

标签:ati   cli   crt   code   $1   client   dex   ssl   cert   

原文地址:https://www.cnblogs.com/manu24/p/14216218.html


评论


亲,登录后才可以留言!