Regarding the basic understanding of Nginx, Taobao’s documentation has introduced it very clearly: http://tengine.taobao.org/book/
The following records some specific usage processes. Easy to check in the future.
1. Overall configuration steps:
- Install Nginx.
- Install dependency packages, including pcre and zlib dependencies. Search the yum list under the root authority of centos7 and then install it.
- Download Nginx. ./configure ---> make ---> make install. (If the installation is successful, you will know where it is installed by looking at the prompts, usually in /usr/local/nginx)
- Visit wget 127.0.0.1 to see the installation success.
- Prepare a machine to put the Web application. For example, my application address is 192.168.1.99.157:8081/springmvc. Prepare another machine (the IP of the machine where I installed Nginx is 192.168.199.176) and install the above Nginx (in fact, you can also test it with the same machine, using different ports as different machines)
- After installing Nginx Modify the nginx.conf main configuration file on the machine. For example, the following configuration file (beta version):
worker_processes 2;
events {
worker_connections 1024;
}
http {
server_tokens off;
include mime.types;
default_type application/octet-stream;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
tcp_nopush on;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 128k;
proxy_ignore_client_abort on;
gzip on;
gzip_http_version 1.1;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_comp_level 2;
gzip_vary on;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
upstream apm {
server 192.168.199.157:8081;
}
server {
listen 8080;
server_name 192.168.199.176;
charset utf-8;
location /springmvc/ {
proxy_pass http://apm;
}
}
sendfile on;
keepalive_timeout 65;
}
- When accessing 192.168.199.176:8080/springmvc/, the homepage of 192.168.199.157:8081/springmvc was successfully accessed
Copyright statement: This article An original article for the blogger, not a blogger No reproduction allowed with permission of the owner.
The above introduces the Nginx reverse proxy Demo, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.