In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to use Nginx to define header information". In daily operation, I believe that many people have doubts about how to use Nginx to define header information. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use Nginx to define Header header information". Next, please follow the editor to study!
The Nginx in my server did not add this module when compiling. Use-V to view the compilation parameters of the current Nginx:
[root@z-dig] # nginx-Vnginx version: www.z-dig.combuilt by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) built with OpenSSL 1.0.1e-fips 11 Feb 2013TLS SNI support enabledconfigure arguments:-- prefix=/usr/local/nginx-- user=www-- group=www\-- with-http_ssl_module-- with-http_stub_status_ module [root @ z-dig ~] #
Download the module from the official website:
[root@z-dig ~] # cd / usr/local/src/ [root@z-dig src] # wget, https://codeload.github.com/openresty/headers-more-nginx-module/zip/master\-O. / headers-more-nginx-module-master.zip [root@z-dig src] # unzip headers-more-nginx-module-master.zip
Before recompiling Nginx, request the Header information of www.z-dig.com:
[root@KVM] # curl-I www.z-dig.comHTTP/1.1 200 OKServer: www.z-dig.comDate: Sat, 23 Apr 2016 11:25:15 GMTContent-Type: text/html; charset=UTF-8Connection: keep-aliveX-Powered-By: PHP/5.6.17Vary: Accept-Encoding, CookieCache-Control: max-age=3, must-revalidateWP-Super-Cache: Served supercache file from PHP [root@KVM] #
Now recompile Nginx and update smoothly:
[root@z-dig] # cd / usr/local/src/nginx [root@z-dig nginx] # make cleanrm-rf Makefile objs [root@z-dig nginx] #. / configure-- prefix=/usr/local/nginx-- user=www-- group=www\-- with-http_ssl_module-- with-http_stub_status_module\-- add-module=/usr/local/src/headers-more-nginx-module-master [root@z-dig nginx] # make [root@z-dig nginx ] # make install [root@z-dig nginx] # kill-s USR2 `cat / usr/local/nginx/logs/ nginx.pid` [root@z-dig nginx] # ps-ef | grep nginxroot 2017 10 Apr21? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginxwww 2018 2017 0 Apr21? 00:00:30 nginx: worker process root 21717 2017 0 19:41? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginxwww 21718 21717 0 19:41? 00:00:00 nginx: worker process root 21856 18312 0 19:45 pts/2 00:00:00 grep nginx [root@z-dig nginx] # kill-s WINCH `cat / usr/local/nginx/logs/ nginx.pid.oldbin` [root@z-dig nginx] # ps-ef | grep nginxroot 2017 10 Apr21? 00:00:00 nginx: master process / usr/local / nginx/sbin/nginxroot 21717 2017 0 19:41? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginxwww 21718 21717 19:41? 00:00:00 nginx: worker process root 21943 18312 0 19:49 pts/2 00:00:00 grep nginx [root@z-dig nginx] # kill-s QUIT `cat / usr/local/nginx/logs/ nginx.pid.oldbin` [root@z-dig nginx] # ps- Ef | grep nginxroot 21717 1 0 19:41? 00:00:00 nginx: master process / usr/local/nginx/sbin/nginxwww 21718 21717 0 19:41? 00:00:00 nginx: worker process root 22050 18312 0 19:54 pts/2 00:00:00 grep nginx [root@z-dig nginx] #
At this point Nginx has been recompiled and smoothly upgraded successfully.
Add the code to the configuration file of Nginx to delete the X-Powered-By and WP-Super-Cache in the Header that you previously requested the website to return:
More_clear_headers 'XMUE powerhouse BYBYOBYTERBYOBYBYOBYBYOBYTH: more_clear_headers 'XMULI powerhouse BYBYPERATION 'WP-Super-Cache'; [root@z-dig] # nginx-tnginx: the configuration file / usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file / usr/local/nginx/conf/nginx.conf test is successful [root@z-dig] # nginx-s reload
Request to see the effect again:
[root@KVM] # curl-I www.z-dig.comHTTP/1.1 200 OKServer: www.z-dig.comDate: Sat, 23 Apr 2016 12:03:04 GMTContent-Type: text/html; charset=UTF-8Connection: keep-aliveVary: Accept-Encoding, CookieCache-Control: max-age=3, must-revalidate [root@KVM ~] #
After testing, the Header specified information in the request return has been successfully deleted.
At this point, the study on "how to use Nginx to define header information" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.