[Nginx] 4xx and 5xx retain custom HeadersProblem
If the status code returned by the request is 404 or 50x, the custom header is still returned.
Analysis and Solution
The add_header section in the nginx document contains the following sentence:
Adds the specified field to a response header provided that the response code equals 200,201,204,206,301,302,303,304, or 307. A value can contain variables.
That is to say, add_header generally does not apply to 4xx and 5xx responses.
However, you can
This article describes how to use the Lua script in nginx. The third-party module LUA-nginx-module is used to call the Lua script in nginx. A Configuration example is provided.Lua is a language similar to Javascript. ngix_lua also uses asynchronous single-thread, and its syntax is even simpler than Js. According to previous evaluations, the performance of ngix_lua is almost node. JS.Nginx features1. Popular High-Performance HTTP servers2. event-driven (asynchronous) Architecture3. A small amount
implemented the idea of maintaining the same type definition for relational databases and redis BY USING THE ORM and deserialization methods, and the cached data is quasi-real-time, if the requirements are completely consistent, the version queried from the relational database should be provided. In addition, to get rid of the direct dependency on redis, you can use openresty to achieve transparent access to resources. This is not the focus of this a
Oneinstack 1.3 was released, This script was written using the shell, in order to quickly deploy LNMP/LAMP/LNMPA/LNMT (Linux, nginx/tengine/openresty, mysql/mariadb/in production environments) Percona, PHP, Apache, Tomcat) for CentOS 5~7 (including redhat), Debian 6~8, Ubuntu 12~16 32-bit and 64-bit.
The original project with Openresty Nginx+lua implementation Server,lua call C dynamic link library, to use OPENSS to do the signature, and generate 130 bytes (128 signature + 2 bit custom bytes) length of the file.nginx:location/Get/Key {Content_by_lua_file'/data/www/sign.lua'; }sign.lualocal FFI= Require"FFI"--Dynamic Link gen_sig_ex_x.c,load ("") Name rules, lib***. solocal GS= Ffi.load ("Sin") ffi.cdef[[intGen_main (Char*param,unsignedChar*signatu
=Args[' AcId ']LocalKey= ' AC ' ..AcIdLocalExpire= 5 * - --cache time 5 minutesLocalValue=Dict.GetData(Key,Expire)if notValue Then LocalRes=Ngx.Location.Capture('/a.json ') ifRes.Status== $ Then --Dict is a script to handle the storage and reading logicDict.SetData(Key,Res.Body) ElseNgx.Say(Dict.GetData(Key)) EndElse --Ngx.log (4, type (value))Ngx.Say(Value)EndIn Dict, we can convert the interface data into HTML fragments and store them through templates. In this way, t
host's port such as Docker run-d-pBayi: thecentos-nginx/usr/local/openresty/nginx/sbin/Nginx Docker Run-d-p192.168.9.11:2201: ANGINX/CENTOS/USR/SBIN/SSHD-D with SSH [email protected]192.168.9.11-P2201connecting containers, Tip: Connection to192.168.1.205Closed. (This issue has not been resolved!!!) Docker commit[Repo:tag] solid a container into a new image, followed by the Repo:tag optional Docker buildlook for a configuration file named Dockerfile u
Greenev is a Python Network Service framework based on the Greenlet, event-driven, non-blocking socket model, which makes it possible to write synchronous code without the benefit of asynchronous execution.This project was inspired by Gevent, Openresty, Alilua, Skynet, Clowwindy/ssloop, and expressed gratitude here.
Reactor mode uses IO multiplexing mechanism based on Epoll, Kqueue, poll, select
Completion of scheduling of Upper Greenlet
phpizeRefresh2 Installing Memcache1 decompression2 Using Phpzie3 for Configure4 Compiling and installing5 loading the corresponding memcache module into PHP6 access in PHP without booting memcache7 copying Memcache-related packets8 modifying managed users and linked hosts9 Restart PHP to load the memcache dynamic module10 access to see if the above configuration is correct11 Currently there is no access in the case of the proportion3 Installing Memecached server 1 Installation2 Start and view P
Recently on new projects, to build nginx to ensure security, the decision to install the WAF module, the following is the specific steps, first download the required installation package, for each installation:
wget http://luajit.org/download/LuaJIT-2.0.3.tar.gz
tar-zxvf luajit-2.0.3.tar.gz
cd LuaJIT-2.0.3
make Make
Install
Then download the Nginx,
wget http://nginx.org/download/nginx-1.7.6.tar.gz
TAR-ZXVF nginx-1.7.6.tar.gz
Download Ngx_devel_kit,
wget http
How LUA compiles into Nginx
1, the first installation Lua-jit, online said can also download Lua, but Lua-jit efficiency is high, address: http://luajit.org/download.htmlI'm under the 2.0.3 version.After the decompression, the direct made make install on it, the default installation in the/usr/local directory
2, download NGX devel packageAddress: Https://github.com/simpl/ngx_devel_kit/tagsNote that this is a nginx extension that does not require compilation
3, download the LUA extension of N
]+) x ([0-9]+)");
If Index then Originaluri = string.sub (Ngx.var.uri, 0, index-2);
Area = String.sub (Ngx.var.uri, index);
index1 = String.find (Area, "([.])");
AREA1 = string.sub (area, 0, index1-1);
Local index2 = String.find (Originalfile, "([0-9]+) x ([0-9]+)");
OriginalFile1 = string.sub (originalfile, 0, index2-2) End of local image_sizes = {"80x80", "800x600", "40x40", "60x60"}; function table.contains (table, Element) for _, value in pairs (table) do if value = = Element then
. If you do not store the database, where should it be stored? 2. The client obtains the token certainly to encrypt the storage, sends the token to decrypt again. Is it stored in a database or a configuration file?
Token is a volatile data, lost nothing more than let the user login again, Sina micro-blog to let me log on again, anyway this matter I do not care.So if you think the normal database tables won't hold up, can be put into the Mssql/mysql memory table (but it is said that MySQL's memor
Operation Statistics Technical Support general Monitoring APM statistical analysis Continuous integration Jenkins environment separation Automation operation Dimension ansible puppet chef Test TDD theory Unit test pressure test full link pressure measurement A/b Quasi-KVM Xen OpenVZ Container Technology Docker cloud technology OpenStack DEVOPS Document management middleware Web Server Nginx openresty Apache Httpd Tomcat Jetty cache Local Cache Gues
Ngx_http_core module in the access phase.Satisfy all (with relationship)Satisfy any (or relationship)
Try-filesConfiguration Item Try_files Processing phaseFeatures specifically designed to implement the standard configuration Directive try_filesIf none of the file system objects corresponding to the previous N-1 parameters exist, the try-files phase immediately initiates the URI specified by the "internal jump" to the last parameter (that is, the nth argument).
ContentContent Generation Phas
latter command, streaming processing, as long as the learning of this command, there are many seemingly complex things, have become unusually simple.
Described above are all commands, and then introduce a direct output of HTML, in fact, is the use of go-access to analyze the Nginx log
Cat/usr/local/nginx/logs/access.log | Docker run--rm-i diyan/goaccess--time-format= '%h:%m:%s '--date-format= '%d/%b/%y '--log-format= ' '%H%^[%d:%t '%^] "% R "%s%b"%R "%u" ' > index.html
Go-access is in the
Computer principle CPU
Multilevel cache process Line Cheng Linux design pattern
Six principles of design pattern 23 common design Patterns Application Scene single case pattern responsibility chain pattern MVC IOC AOP UML Micro Service Idea
Conway Law Transportation Statistics Technical Support
General Monitoring APM Statistical analysis Continuous Integration (CI/CD)
Jenkins Environment Separation Automation Operation dimension
Ansible Puppet Chef Test
TDD theory Unit test pressure test full
correctly. Security protection, based on Ngx_lua development, does not allow for effective security detection of the 100th subsequent parameter submitted by an attacker, bypassing security defenses. Detailed analysis I wrote another article: "Break the Web security protection based on Openresty (cve-2018-9230)"Mysql Bypass instance:Mssql Bypass Example:0x03 ENDThese three postures mainly utilize HPP, which combines the characteristics and differences
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.