• Nginx实现静态服务器+https+负载均衡


    #user  nobody;
    # 进程数=CPU总核数
    worker_processes  2;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        # 反向代理
        upstream backend.com {
            server webappIp1:prot weight=1;
            server webappIp2:prot weight=2;
        }
    
        server {
            listen       80;
            server_name  www.guotanghang.com;
            
            #charset koi8-r;
            #access_log  logs/host.access.log  main;
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            return      301 https://$server_name$request_uri;
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }   
    
        server {
            listen       443 ssl;
            server_name  www.yoursite.com;
            #ssl on;
    
            ssl_certificate      cert/yourCert.pem;
            ssl_certificate_key  cert/yourCert.key;
    
            #ssl_session_cache    shared:SSL:1m;
            ssl_session_timeout  5m;
    
            #ssl_ciphers  HIGH:!aNULL:!MD5;
            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 / {
                root   E:\webapp\demo;
                index  index.html index.htm;
    
                proxy_hide_header Vary;
                proxy_hide_header X-Powered-By;
    
                proxy_set_header Host            $host;
                proxy_set_header X-Real_IP       $host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            }
    
            # 负载均衡路由
            location /war_name {
                proxy_pass http://backend.com;
                proxy_redirect default;
            }
        }
    
    }
        
  • 相关阅读:
    从键盘输入一串数据,以“exit"结束输入,且输出数据。
    判断指定盘符下文件夹是否存在
    java 输出图形
    Object对象类
    java继承
    Java封装
    java环境搭建系列:JDK环境变量详细配置
    java环境搭建系列:JDK从下载安装到简单使用
    ORACLE常见错误代码的分析与解决
    Java与C++面向对象不同点
  • 原文地址:https://www.cnblogs.com/ifindu-san/p/7266756.html
Copyright © 2020-2023  润新知