默认Nginx显示不完全的http请求url地址,通过配置Nginx的nginx.conf文件,可以实现显示完整的http请求地址。

Nginx的nginx.conf的原始默认配置文件内容:


#user  nobody;
worker_processes  1;#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;server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

(1)开始修改配置:

打开http里面的log_format,即把http里面的log_format前面的#号注释打开,并修改成如下:

 log_format main '$http_x_forwarded_for - $remote_user [$time_local] ''"$request_method $scheme://$host$request_uri $server_protocol" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $request_time';

把http下面的#access_log打开

access_log  logs/access.log  main;

打开http -> server 里面的access_log

access_log  logs/host.access.log  main;

最终,nginx.conf变为:


#user  nobody;
worker_processes  1;#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"';   log_format main '$http_x_forwarded_for - $remote_user [$time_local] ''"$request_method $scheme://$host$request_uri $server_protocol" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $request_time';access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;#gzip  on;server {listen       80;server_name  localhost;#charset koi8-r;access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443 ssl;#    server_name  localhost;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_cache    shared:SSL:1m;#    ssl_session_timeout  5m;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers  on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

再次载入nginx:

nginx -s reload

此时,再次访问的url请求地址,就会被完整的记录进./logs/host.access文件里面。

Nginx配置显示http完整的请求URL相关推荐

  1. Nginx配置valid_referer解决跨站请求伪造(CSRF)

    Nginx配置valid_referer解决跨站请求伪造(CSRF) 文章目录 Nginx配置valid_referer解决跨站请求伪造(CSRF) 漏洞说明 漏洞描述 危害等级 修复建议 漏洞复现 ...

  2. nginx配置连接数及限制客户端请求

    1.nginx配置连接数 准备两台linux服务器,一台安装nginx,一台安装ApacheBench工具对nginx服务器进行测 ApacheBench 是一个指令列程式,专门用来执行网站服务器的运 ...

  3. nginx配置url重定向_Nginx配置URL重写

    URL重写是指通过配置conf文件,以让网站的URL中达到某种状态时则定向/跳转到某个规则,比如常见的伪静态.301重定向.浏览器定向等. Nginx允许使用正则表达式重写URI(需PCRE库),并且 ...

  4. nginx配置url重写

    url重写是指通过配置conf文件,以让网站的url中达到某种状态时则定向/跳转到某个规则,比如常见的伪静态.301重定向.浏览器定向等 rewrite 语法 在配置文件的server块中写,如: s ...

  5. Nginx配置SSL证书(CentOS环境),实现https请求

    目录 一.Nginx配置SSL 1.证书申请 二.配置SSL 2.1 证书上传 2.2 HTTPS server配置 2.2.3 配置转发 三.配置问题 四.配置示例 1.nginx.conf配置SS ...

  6. nginx php配置重写,nginx 配置 php url 重写

    nginx 配置 Https php url 重写server { listen 80; server_name www.goodsunlc.com; rewrite ^(.*) https://$s ...

  7. 如何解决请求URL长度超过配置的maxurlLength值问题

    当我们批量请求的数据太多时,会出现请求的url长度超过配置maxurllength值的问题(比如一次性操作1000条数据) 1.问题描述: 我在进行批量选择单据进行发送时,出现这个问题(批量500条) ...

  8. Nginx配置跨域请求 Access-Control-Allow-Origin *

    Nginx配置跨域请求 Access-Control-Allow-Origin * 当出现403跨域错误的时候 No 'Access-Control-Allow-Origin' header is p ...

  9. 【nginx配置】 proxy_pass反向代理配置中url后面加不加/的说明

    在日常的web网站部署中,经常会用到nginx的proxy_pass反向代理,有一个配置需要弄清楚:配置proxy_pass时,当在后面的url加上了/,相当于是绝对根路径,则nginx不会把loca ...

最新文章

  1. OpenCV+python:色彩空间转换及色彩通道的分离和合并
  2. [转载]注册机破解法的原理以及应对方法
  3. 【Android 逆向】Android 进程简介 ( Android 应用启动流程 )
  4. 百度危矣:乱评程苓峰《360的章鱼手要抢谁家饭碗?》
  5. 数据分析:2020年3月汽车工业经济运行情况
  6. Redis-01Redis概述
  7. 副本放置策略Copysets论文解读及工程实践
  8. android吸附菜单,Android仿微博、人人Feed详情页吸附导航栏
  9. Winform DataGridView修改数据源界面不刷新问题
  10. Linux防火墙开关命令
  11. Java 反射机制 是什么
  12. 第三方支付接口怎么测试
  13. 解决树莓派中文显示框框乱码
  14. 一年级口算题20以内加减法有哪些技巧
  15. Mac无法识别硬盘解决办法
  16. 3D建模和渲染吃什么硬件?新手避坑指南
  17. Hadoop 3.x主要变化(相对于Hadoop 2.x)
  18. Python_oldboy_自动化运维之路_线程,进程,协程(十一)
  19. java数字音频最强教程之如何检测一段音频中是否有声音
  20. Spring MVC原理解析

热门文章

  1. 全力赶超ERP 我国协同软件市场现状与发展(zt)
  2. 互联网金融 最不该放松安全这根神经
  3. vue打包(npm run build)
  4. windowsXP中任务管理器中的PF使用率的意思
  5. ubuntu20.04安装python3.9并设置为默认的python3
  6. Cadence PCB仿真使用Allegro PCB SI生成串扰细节报告Crosstalk Detailed Report及报告导读图文教程
  7. 二类医疗器械定义及分类
  8. angular 引入本地图片
  9. 谷歌浏览器控制台调试器的基本使用方法,常用方法必备,手把手教学
  10. 为什么至少三个哨兵_Redis集群哨兵机制