Main file: (/etc/nginx/ngnix.conf) The places that need to be modified have been added, and the others do not need to modify it.
# for more information on configuration, see:
# * Official English documentation: http://nginx.org/en/docs/
# * Office Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processses auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/readme.dynamic.
Include /usr/share/nginx/modules/*.conf;
Events {
worker_connections 1024;
}
http {
log_format main '$ remote_addr -$ remote_user [$ Time_local] "$ Request"'
'$ Status $ Body_Bytes_SENT "$ http_referr"'
'"$ http_user_agent" "$ http_x_Forwardeded_FOR"';
access_log /var/log/nginx/access.log main;
Sendfile on;
tcp_nopush on;
tcp_nodelay on;
Keepalive_timeout 65;
types_hash_max_size 2048;
client_max_body_size 10m; #Allows users to submit maximum restrictions on files, and may need to be modified
Include /etc/nginx/mime.types;
default_type application/octet -stream;
# Load model configuration files from the /etc/nginx/conf.d directory.
# See http://ngginx.org/en/docs/ngx_core_module.html#include
# for more information.
#Local site: live: 127.0.0.1: 8000
upstream live {
Server 127.0.0.1:8000;
}
include /etc/nginx/conf.d/*.conf;
Server {
Listen 80 default_server;
Listen [::]: 80 default_server;
Server_name _;
root/usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
}
error_page 404 /404.html;
local = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
# Settings for a tls enabled server.
#
# Server {
# Listen 443 SSL http2 default_server;
# Listen [::]: 443 SSL http2 default_server;
# server_name _;
# root/usr/share/nginx/html;
#
# ssl_certified "/etc/pki/nginx/server.crt";
# ssl_certified_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared: ssl: 1m;
# SSL_SESSION_TIMEOUT 10M;
# SSL_CIPHERS HIGH:! Anull:! MD5;
# SSL_PREFER_SERVER_CIPHERS On;
#
# # Load Configuration Files for the Default Server Block.
# include /etc/nginx/default.d/*.conf;
#
# local / {{
#}
#
# error_page 404 /404.html;
# local = /40x.html {
#}
#
# ERROR_PAGE 500 502 503 504 /50x.html;
# local = /50x.html {
#}
#}
}
Configuration file (/etc/nginx/conf.d/default.conf)
server {
Listen 8080 default_server; #NGINX service monitoring port
#Listen [::]: 80 default_server;
Server_name _;
root/usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#Analyzing static files (the parameters are the type of files they support)
local ~.*\. (jpg | gif | jpeg | css | js) {
root /Home /Live; #r r r r
Expires 1H; #Expires defines the time of the user browser cache of 7 days. If the static page is not updated often, it can be set longer, which can save bandwidth and alleviate the pressure of the server's pressure on the server.
}
#Analyze the web root directory access request (my understanding)
location / {
proxy_pass http:// live; #reverse proxy, live is a local site, the outer network is not visited
proxy_set_header x-real-in $ remote_addr;
}
error_page 404 /404.html;
local = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}