• nginx反向代理批量实现https协议访问


    我们进入大多数HTTPS网站ie浏览器都会给出相关提醒了,但我配置了一台HTTPS代理机器发现css与js都加载不了,这个有朋友说是https页面,如果加载http协议的内容,会被认为页面不安全,所以就会弹出提醒框了。

    HTTPS是什么

    HTTPS(全称:Hypertext Transfer Protocol over Secure Socket Layer),是以安全为目标的HTTP通道,简单讲是HTTP的安全版。即HTTP下加入SSL层,HTTPS的安全基础是SSL,因此加密的详细内容就需要SSL。 它是一个URI scheme(抽象标识符体系),句法类同http:体系。用于安全的HTTP数据传输。https:URL表明它使用了HTTP,但HTTPS存在不同于HTTP的默认端口及一个加密/身份验证层(在HTTP与TCP之间)。这个系统的最初研发由网景公司进行,提供了身份验证与加密通讯方法,现在它被广泛用于万维网上安全敏感的通讯,例如交易支付方面

    解决办法

     代码如下 复制代码
    sever{ 
    listen 80; 
    sever_name www.你的域名.net; 
    root /home/webroot/www/; 
    index index.php index.html; 
    # ... 

    sever{ 
    listen 80; 
    sever_name img.你的域名.net; 
    root /home/webroot/img/; 
    index index.php index.html; 
    # ... 

    sever{ 
    listen 80; 
    sever_name static.你的域名.net; 
    root /home/webroot/static/; 
    index index.php index.html; 
    # ... 

    sever{ 
    listen 80; 
    sever_name upload.你的域名.net; 
    root /home/webroot/upload/; 
    index index.php index.html; 
    # ... 

    server { 
    listen 443; 
    server_name www.你的域名.net img.你的域名.net static.你的域名.net upload.你的域名.net; 
    ssl on; 
    ssl_certificate /usr/local/nginx/conf/你的域名.net.crt; 
    ssl_certificate_key /usr/local/nginx/conf/你的域名.net.key; 
      
    location /{ 
    proxy_pass http://127.0.0.1:80; 
    proxy_redirect off; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $host; 
    proxy_set_header SSL '1'; 
    proxy_redirect http:// https://; 

    }

    这样配置好,访问:

     代码如下 复制代码

    https://www.你的域名.net/ 
      
    https://img.你的域名.net/ 
      
      
    https://static.你的域名.net/ 
      
      
    https://upload.你的域名.net/

    会被反向代理至:

    http://www.你的域名.net/ 
      
    http://img.你的域名.net/ 
      
      
    http://static.你的域名.net/ 
      
      
    http://upload.你的域名.net/

  • 相关阅读:
    2
    1
    java10
    java8
    java9
    java7
    java6
    java5
    java4
    java3
  • 原文地址:https://www.cnblogs.com/archoncap/p/5156673.html
Copyright © 2020-2023  润新知