nginx 开启x-forward

摘要:
192.168.137.2node1:/etc/nginx#cat/etc/nginx/nginx。confworker_进程1;#error_loglogs/error。日志;#error_loglogs/error。日志通知;#error_loglogs/error。登录信息;事件{worker_connections1024;}#http确认
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"



免责声明:文章转载自《nginx 开启x-forward》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇聚类之k-means附代码IntelliJ IDEA教程之如何clean或者install Maven项目下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

日志切割之Logrotate

1、关于日志切割   日志文件包含了关于系统中发生的事件的有用信息,在排障过程中或者系统性能分析时经常被用到。对于忙碌的服务器,日志文件大小会增长极快,服务器会很快消耗磁盘空间,这成了个问题。除此之外,处理一个单个的庞大日志文件也常常是件十分棘手的事。  logrotate是个十分有用的工具,它可以自动对日志进行截断(或轮循)、压缩以及删除旧的日志文件。例...

nginx安装配置lua支持

nginx安装很简单,配置lua相关的支持就需要额外的安装一些库和编译。 一、准备环境 yum -y install lua*wget https://luajit.org/download/LuaJIT-2.0.4.tar.gz wget https://github.com/simpl/ngx_devel_kit/archive/v0.2.19.tar...

Spring框架系列(五)--Spring AOP以及实现用户登录权限控制

背景:   当需要为多个不具有继承关系的对象引入一个公共行为,例如日志、权限验证、事务等功能时。如果使用OOP,需要为每个Bean引入这些公共 行为。会产生大量重复代码,并且不利用维护,AOP就是为了解决这个问题。 AOP:   就是上面的解释,可以理解一种思想,不是Java独有的,作用是对方法进行拦截处理或增强处理。而在Java中我们使用Spring...

记CentOs服务器内存使用满的解决办法

使用的一个应用服务器,weblogic部署,nginx分配,在使用了半个月的时间里,服务器内存达到杀掉服务器进程之后查看被删除但是仍然被应用程序占用的文件列表由于我删掉了日志里所以东西,所以导致后来我又得使用了一个命令由于我删了日志里的ngnix.pid 但是我删除的只是结尾log日志呀,不知道怎么就把pid结尾文件删除了,奇怪反正就报这个错“/usr/l...

linux总结

用户登录 root用户 是一个特殊的管理账号,也可以成为超级管理员 root用户对系统有完全控制的权限 对系统的损害会无限大 在工作中,如果没有特殊的必要,尽量不要使用root 普通用户 权限有限 对系统的损害会小 终端 分类 设备终端 物理终端 虚拟终端 ctrl+alt+f[1-6] /dev/tty# 图形终端 /dev/tty7...

nginx 414 Request-URI Too Large

症状 nginx 414 Request-URI Too Large #客户端请求头缓冲区大小,如果请求头总长度大于小于128k,则使用此缓冲区, #请求头总长度大于128k时使用large_client_header_buffers设置的缓存区client_header_buffer_size 128k; #large_client_header_buf...