Description of the Nginx.conf configuration file


#user nobody;

#Number of open processes <=Number of CPUs 
worker_processes 1;

#Error log storage location#
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#Process number save file
#pid logs/nginx.pid;

#Maximum number of connections per process (maximum connection = number of connections x number of processes) How many connections are allowed to be generated by each worker at the same time, default 1024
events {
worker_connections 1024;
}


http {
#file extension and file type mapping table
include mime.types; #default
file type
default_type application/octet-stream;

#Log file output format This location is relative to the global setting
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#Request log storage location#
access_log logs/access.log main; #Open

the send file
sendfile on;
#tcp_nopush on;

#keepalive_timeout 0; #Connection
timeout
keepalive_timeout 65;

#Turn on gzip compression#gzip
on; #Set the

request buffer#
client_header_buffer_size 1k;
#large_client_header_buffers 4 4k; #Set

the server list for load balancing
#upstream myproject {
#weigth parameter indicates the weight, the higher the weight, the probability of being assigned The larger
#max_fails is, when #max_fails requests fail, it means that the backend server is unavailable. The default value is 1. Setting it to 0 can disable the check
. #fail_timeout In the future #fail_timeout time, nginx will not send requests to the past Check out servers marked as unavailable
#}

#webapp
#upstream myapp {
# server 192.168.1.171:8080 weight=1 max_fails=2 fail_timeout=30s;
# server 192.168.1.172:8080 weight=1 max_fails=2 fail_timeout=30s;
#}

#Configure virtual host, based on domain name, ip and port
server {
#Listen on port
listen 80;
#Listen on domain name
server_name localhost;

#charset koi8-r;

#nginx access logs are placed under logs/host.access.log, and use the main format (you can also customize the format)
#access_log logs/host.access.log main;

#Returned corresponding file address
location / { #Set
the client's real ip address
#proxy_set_header X-real-ip $remote_addr; #Load
balancing reverse proxy#
proxy_pass http://myapp; #Return

the root path address (relative path: relative in /usr/local/nginx/)
root html;
#default access file
index index.html index.htm;
}

#Configure reverse proxy tomcat server: intercept requests at the end of .jsp and redirect to tomcat
#location ~ \.jsp$ {
# proxy_pass http://192.168.1.171:8080;
#}

#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
# #Error

pages and their return addresses
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} #Virtual

host configuration:
server {
listen 1234;
server_name bhz.com;
location / {
#Regular expression matching uri method: create a test123.html under /usr/local/nginx/bhz.com and then use regular matching
#location ~ test {
## Rewrite syntax: if return (condition = ~ ~*)
#if ($remote_addr = 192.168.1.200) {
# return 401;
#}

#if ($http_user_agent ~* firefox) {
# rewrite ^.*$ /firefox.html;
# break;
#}

root bhz.com;
index index .html;
}

#location /goods {
# rewrite "goods-(\d{1,5})\.html" /goods-ctrl.html;
# root bhz.com;
# index index.html;
#} #Configure

access log
access_log logs/bhz.com. access.log main;
}


# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;

# location / {
# root html;
# index index.html index.htm;
# }
#}


# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;

# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;

# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;

# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;

# location / {
# root html;
# index index.html index.htm;
# }
#}

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324581928&siteId=291194637