• nginx的conf文件,两种配置方式,第一种无ssl证书,第二种有ssl证书。


    以下为无ssl证书配置的请求转发

    server {
        listen 80;
        server_name api.******.com;
        location ~* /union {
          client_max_body_size   3000m;
          proxy_next_upstream http_502 http_504 error timeout invalid_header;
    
          proxy_set_header   Host $host;
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   X-Real-PORT $remote_port;
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    
          proxy_pass http://127.0.0.1:8080;
          proxy_redirect default;
          proxy_connect_timeout 3000;
    
          if ($http_origin ~ https://(.*).******.com){
              set $allow_url $http_origin;
          }
    
          if ($request_method = OPTIONS) {
              add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, HEAD";
    #         add_header Access-Control-Allow-Origin $allow_url;
              add_header Access-Control-Allow-Origin *;
              add_header Access-Control-Allow-Headers "Cookie,Set-Cookie,Origin,X-Requested-With,token,authorization,Accept,Content-type";
              add_header Access-Control-Allow-Credentials "true";
              add_header Content-Type "text/plain; charset=utf-8";
              add_header Content-Length 0;
            return 204;
          }
        }
    }
    

      

    以下为有ssl请求转发

    将以下代码替换成自己的证书路径:

    ssl_certificate /etc/nginx/cert/api.pem;
    ssl_certificate_key /etc/nginx/cert/api.key;

    server {
        listen 80;
        server_name api.******.com;
        rewrite ^(.*)$ https://${server_name}$1 permanent;
    }
    
    server {
        listen 443;
        server_name api.******.com;
        ssl on;
        ssl_certificate   /etc/nginx/cert/api.pem;
        ssl_certificate_key  /etc/nginx/cert/api.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;
        location ~* /union {
          client_max_body_size   3000m;
          proxy_next_upstream http_502 http_504 error timeout invalid_header;
    
          proxy_set_header   Host $host;
          proxy_set_header   X-Real-IP $remote_addr;
          proxy_set_header   X-Real-PORT $remote_port;
          proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    
          proxy_pass http://127.0.0.1:8080;
          proxy_redirect default;
          proxy_connect_timeout 3000;
    
          if ($request_method = OPTIONS) {
              add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, HEAD";
              add_header Access-Control-Allow-Origin *;
              add_header Access-Control-Allow-Headers "Cookie,Set-Cookie,Origin,X-Requested-With,token,authorization,Accept,Content-type";
              add_header Access-Control-Allow-Credentials "true";
              add_header Content-Type "text/plain; charset=utf-8";
              add_header Content-Length 0;
            return 204;
          }
        }
    }
    

      

  • 相关阅读:
    移动Web应用开发入门指南——视觉篇
    Dapper的完整扩展(转)
    Dapper.net 在Parameterized时对于String的扩展(转)
    Entity Framework 5.0
    用事实说话,成熟的ORM性能不是瓶颈,灵活性不是问题:EF5.0、PDF.NET5.0、Dapper原理分析与测试手记(转)
    雅虎团队:网站性能优化的35条黄金守则(转)
    在window server 2008 64位系统上 发布网站的过程中遇到的问题(转)
    sqlserver能否调用webservice发送短信呢?
    数据库优化方案(转)
    SQL点滴之编辑数据(转)
  • 原文地址:https://www.cnblogs.com/hahahehexixihoho/p/10797657.html
Copyright © 2020-2023  润新知