current location:Home > Technical Articles > Operation and Maintenance > Nginx
- Direction:
- All web3.0 Backend Development Web Front-end Database Operation and Maintenance Development Tools PHP Framework Daily Programming WeChat Applet Common Problem Other Tech CMS Tutorial Java System Tutorial Computer Tutorials Hardware Tutorial Mobile Tutorial Software Tutorial Mobile Game Tutorial
- Classify:
-
- Nginx add_header instruction example analysis
- Preface As we all know, the nginx configuration file sets the responseheader by using the add_header directive. Use curl to check the information of a site and find that the returned header is different from what you expected: http/2200date:thu,07feb201904:26:38gmtcontent-type:text/html;charset=utf-8vary:accept-encoding,cookiecache- control:max-age=3,must-revalidatelast-modified:thu,07feb20190
- Nginx 1544 2023-05-17 18:37:06
-
- How Nginx dynamically forwards to upstream based on the path in the url
- Scenario 1/svr1/xxxx?yyy is forwarded to svr1:8080/xxxx?yyy/svr2/xxxx?yyy and forwarded to svr2:8080/xxxx?yyy. The configuration is as follows: location~*/(srv[1-9]+)/( .*)${allowall;proxy_passhttp://$1/$2$is_args$args;proxy_set_headerhost$host;proxy_set_headerx-forwarded-for$forwarded_addr;}upstreamsrv1{serversrv1-
- Nginx 1476 2023-05-17 18:28:06
-
- How to solve Nginx 404 error
- Recently, when deploying projects, some problems occurred. As shown in the figure, the normal login interface is accessible, but after logging in, a 404 error will be reported when accessing the address. So I went to check if there were any configuration errors, but after checking, I found that nginx. The IPs and ports of the two configuration files conf and config.js are correct. This project has been deployed many times and no such errors have occurred. This is the original untouched decompressed source file of nginx.conf. The circled area is the corresponding IP and listening port that should be configured according to the project configuration. listen corresponds to the port, and server_name corresponds to the accessed IP, but this cannot be done. To solve the problem, we need to add the following sentence tr
- Nginx 16029 2023-05-17 18:23:18
-
- nginx ip blacklist dynamic ban method
- 1. The solution blacklist is persisted to mysql (the common solution is redis, but it is not conducive to control, such as: different IPs set different validity periods, IP crud, statistics, etc.); through lua-nginx-module, in nginx Open up a piece of memory (lua_shared_dict), and Lua will regularly refresh the blacklist from mysql to lua_shared_dict; all requests must be checked with ipcheck in lua_shared_dict. 2. Install 2.1 install luajitcdluajit-2.0.5makemakeinstallprefix=/usr/local/
- Nginx 1417 2023-05-17 17:58:06
-
- How to solve the pitfall of nginx configuration add_header
- Preface add_header is an instruction defined in the headers module. As the name suggests, it is used to add http response headers. But please note that it is just "adding", not rewriting. So if a header already exists, problems will arise if you use add_header again. Moreover, in lower versions of nginx, add_header does not support use in error pages. This is an instruction with many pitfalls. Its processing stage is later than location processing. Although it can be written in location, if another location is rewritten, the unprocessed add_header in the previous location will be lost. For example: location
- Nginx 1816 2023-05-17 17:40:06
-
- How to use Nginx proxy Partainer
- The main purpose is to proxy the Partainer service through nginx and perform unified forwarding through nginx. 1. Start nginx. Start nginx and mount the entire nginx configuration path. The specific nginx configuration can be found in Baidu dockerrun-p80:80-namenginx--restart=always- vnginx/:/etc/nginx-dnginx modify conf.d/default.confupstreamdocker{//the name of the portainer container under the configuration path. If this nginx is not configured, noresolverdefinedtore will be used.
- Nginx 1325 2023-05-17 17:04:06
-
- How to configure ab to do stress testing for Nginx server
- ab is a performance testing tool for apache. You can only install the ab tool. Install abapt-getinstallapache2-utilscentos on ubuntu and install abyuminstallhttpd-tools. Before testing, you need to prepare a simple html, a php, and an image file. Test them separately. We put these three files in the default html directory of the nginx installation directory. After preparation, we can test ab-kc1000-n1000http://localhost/ab.html. This command will use 1000 concurrency and connect 1000 times. The result is as follows
- Nginx 762 2023-05-17 16:40:51
-
- How to use htpasswd to password protect the website in Nginx
- The final effect is similar (the interfaces of different browsers are different): if the authentication fails, an http error will be reported: 401authorizationrequired. To implement such a function, you need to change the server configuration and set the username and password for login. First we need to change the nginx server configuration of the website. For Ubuntu server, this configuration file is usually located at /etc/nginx/sites-enabled/. For example, I use the default configuration file /etc/nginx/sites-enabled/default here. An example: copy the code as follows: server{serve
- Nginx 920 2023-05-17 15:49:06
-
- How to configure blacklist or whitelist function for Nginx server
- 1. Method of defining blacklist or whitelist: 1. Configuration format configuration keyword blacklist or whitelist file storage space white_black_list_confconf/white.listzone=white:2m;|||||||-------- ----------------------------------The storage space size here is 2m. The space size determines the capacity of the black and white list ||---- -------------------------------------------------- ----------------------------------
- Nginx 2297 2023-05-17 15:40:06
-
- How to use Docker to mount volumes to deploy Nginx
- Nginx data volume nginx has many functions, such as forward proxy, reverse proxy, load balancing, transparent proxy, etc. Generally, reverse proxy and load balancing are used more. These operations only need to modify the configuration file, so we only need to synchronize the configuration file locally. The path of the nginx configuration file is etc/nginx/nginx.conf. First create the corresponding directory and file: nginx.conf in the nginx1 directory must also be created, and the content can be left empty. Next, check whether the image is normal: If you have not downloaded the image, use the following command to pull the image (default is the latest version): dockerpullnginx Next, run the container: docker
- Nginx 1131 2023-05-17 15:31:40
-
- How to configure nginx of Laravel Octane and WebSocket in Laradock
- The previous situation describes that after LaravelOctane is installed in laradock, swoole is started. Configuring the port access connection in nginx fails, and error message 502 is reported. The configuration is as follows: location/octane{proxy_passhttp://127.0.0.1:8080;} Reason: Swoole server is in Workspace Running in a container; the Nginx server runs in an Nginx container, and you need to find the Workspace IP and configure it in nginx. Solution: dockerps checks the id of the Workspace container. dockerinspect container id, find Networ
- Nginx 1263 2023-05-17 15:22:06
-
- How to optimize Nginx and Node.js for high-load networks
- If network optimization does not first understand the underlying transmission mechanisms of nginx and node.js and carry out targeted optimization, no matter how detailed the optimization of the two is, it may be in vain. Generally, nginx connects the client and upstream applications through tcpsocket. Our system has many thresholds and restrictions for tcp, which are set through kernel parameters. The default values of these parameters are often set for general purposes and cannot meet the high traffic and short life requirements of web servers. Here are some parameters that are candidates for tuning tcp. To make them effective, you can place them in the /etc/sysctl.conf file, or put them in a new configuration file, such as /etc/sysctl.
- Nginx 1469 2023-05-17 15:13:14
-
- How nginx realizes dynamic and static separation of tomcat
- 1. Why should dynamic and static separation be achieved? 1) nginx has a strong ability to process static resources. The main reason is that nginx’s efficiency in processing static pages is much higher than that of tomcat. If tomcat’s request volume is 1000 times, then nginx’s request volume is 6000 times. , tomcat's throughput per second is 0.6m, and nginx's throughput per second is 3.6m. It can be said that nginx's ability to process static resources is 6 times that of tomcat, and the advantages are evident. 2) Dynamic resources and static resources are separated to make the server structure clearer. 2. Principle of static and dynamic separation. Among the requests received by the server from the client, some are requests for static resources, such as html, css, js and image resources.
- Nginx 856 2023-05-17 14:52:28
-
- How to use nginx rewrite function
- Preface When you browse some websites, have you ever noticed that when you enter: www.abc.com or www.abcd.com, the page can display the homepage content of www.abc.com normally. This is a usage scenario of nginxrewrite. Introduction to rewrite Rewrite is an important basic function provided by the Nginx server. Its main function is to realize URL address rewriting. The rewrite function depends on the support of pcre. Therefore, before compiling and installing the Nginx server, you need to install the pcre library (nginx uses the ngx_http_rewrite_module module to parse and handle the Rewrite function
- Nginx 3401 2023-05-17 13:49:32
-
- How to implement nginx memory pool
- 1. Introduction to the latest stable version nginx1.20.2. In order to allocate memory efficiently and quickly, and reduce memory fragmentation, nginx implements its own basic memory pool component. Main implementation files ngx_palloc.h, ngx_palloc.c 2. Data structure 2.1 Main structure of memory pool typedefstruct{u_char*last;u_char*end;ngx_pool_t*next;ngx_uint_tfailed;}ngx_pool_data_t;structngx_pool_s{ngx_pool_data_td;size_tmax;ngx_poo
- Nginx 1310 2023-05-17 13:26:27