• nginx 开启x-forward


    192.168.137.2
    
    node1:/etc/nginx#cat /etc/nginx/nginx.conf
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    events {
        worker_connections  1024;
    }
    
    # http conf
    http {
        #include     http/common.conf;
        #include     http/cache.conf;
        #include     http/resty.conf;
        #include     http/mime.types;
    
        include     http/*.conf;
    
        include     http/servers/*.conf;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for" "$request_filename"';
      
        access_log  logs/access.log  main;  
        upstream backend1 {
        server 192.168.137.3:8090      weight=5;
        }
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    server{
            listen       8090;
            server_name  localhost;
            ssl on;
            #从腾讯云获取到的第一个文件的全路径
             ssl_certificate /etc/ssl/server.pem;
             ssl_certificate_key /etc/ssl/server.key;
             location ^~ /backoffice
              {
               proxy_pass https://backend1/backoffice;
               proxy_connect_timeout 300;
               proxy_send_timeout 300;
               proxy_read_timeout 300;
               proxy_set_header   Host             $host;
               proxy_set_header   X-Real-IP        $remote_addr;       
               proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
               }
            }
    
    }
    
    打印出的日志:
    
    192.168.137.1 - - [29/Apr/2020:17:29:09 +0800] "GET /backoffice/ HTTP/1.1" 200 215 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/usr/local/nginx/html/backoffice/"
    
    192.168.137.1 - - [29/Apr/2020:17:29:09 +0800] "GET /backoffice/index.css HTTP/1.1" 304 0 "https://192.168.137.2:8090/backoffice/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "-" "/usr/local/nginx/html/backoffice/index.css"
    
    
    
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    events {
        worker_connections  1024;
    }
    
    # http conf
    http {
        #include     http/common.conf;
        #include     http/cache.conf;
        #include     http/resty.conf;
        #include     http/mime.types;
    
        include     http/*.conf;
    
        include     http/servers/*.conf;
        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for" "$request_filename"';
      
        access_log  logs/access.log  main;  
    
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    server{
            listen       8090;
            server_name  localhost;
             ssl on;
            #从腾讯云获取到的第一个文件的全路径
             ssl_certificate /etc/ssl/server.pem;
             ssl_certificate_key /etc/ssl/server.key;
            location / {
            root /var/www/demo/html;
            index  index.html;
            }
           location /backoffice  {
                root /var/www/html;
                index  index.html index.htm;
               if ($request_filename ~  .*.(js|css|htm|html)$)
                     {
                       expires      -1;
                     }
            }
    }
    
    }
    
    
    
    192.168.137.2 - - [09/Apr/2020:08:21:24 +0800] "GET /backoffice/ HTTP/1.0" 200 215 "-" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "192.168.137.1" "/var/www/html/backoffice/index.html"
    192.168.137.2 - - [09/Apr/2020:08:21:24 +0800] "GET /backoffice/index.css HTTP/1.0" 304 0 "https://192.168.137.2:8090/backoffice/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36" "192.168.137.1" "/var/www/html/backoffice/index.css"
    
    
    
    
  • 相关阅读:
    BNUOJ 12756 Social Holidaying(二分匹配)
    HDU 1114 Piggy-Bank(完全背包)
    HDU 2844 Coins (多重背包)
    HDU 2602 Bone Collector(01背包)
    HDU 1171 Big Event in HDU(01背包)
    HDU 2571 命运 (入门dp)
    HDU 1069 Monkey and Banana(最长递减子序列)
    HDU 1160 FatMouse's Speed (最长上升子序列)
    HDU 2594 KMP
    POJ 3783 Balls --扔鸡蛋问题 经典DP
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348392.html
Copyright © 2020-2023  润新知