Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of nginx configuration parameters

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

[root@WEBServer10414 ~] # cat / etc/nginx/nginx.conf

# user nobody;# defines the users and user groups under which nginx runs

User root

The number of worker_processes 8 processes. It is recommended to set it to equal to the total number of cores of CPU.

# error_log logs/error.log;# error Log path

# error_log logs/error.log notice;# error log type, such as [debug | info | notice | warn | error | crit]

# error_log logs/error.log info; error log type

# pid logs/nginx.pid;# process file

Worker_rlimit_nofile 51200th # the maximum number of file descriptors opened by a nginx process, the theoretical value should be the maximum number of open files (system value ulimit)

Events {# operating mode and upper limit of connections

Use epoll;# reference event model [kqueue | rtsig | epoll | / dev/poll | select | poll]

Worker_connections 51200th # maximum number of connections per process

}

Http {# set http server

Include mime.types; # File extension and File Type Mapping Table

Default_type application/octet-stream; # default file type

# log_format main'$remote_addr-$remote_user [$time_local] "$request"'

#'$status $body_bytes_sent "$http_referer"'

#'"$http_user_agent"$http_x_forwarded_for"'

# access_log logs/access.log main

Sendfile on;# turns on efficient file transfer mode

# tcp_nopush on;# to prevent network congestion

# keepalive_timeout 0

Keepalive_timeout 120bot # long connection timeout (in seconds)

Load balancing of upstream backend {# upstream

Ip_hash;# uses ip_hash 's algorithm

Server 50.50.50.16 8020 IP and port number of the realserver

Server 50.50.50.13 8020 reality server's IP and port number

}

# gzip on;# enable gzip to compress output

Server {# configuration of virtual host

Listen 8080; # Port number for virtual host listening

Server_name WEBServer10414; # Domain name or hostname of the virtual host

If ($host ~ * "\ d +\.\ d +") {

Return 400

}

Charset utf-8; default Encoding

# access_log logs/host.access.log main;# defines the access log of this virtual host

Location / {# enable reverse proxy for "/"

# root html

The type of index file recognized by index index.jsp index.html index.htm; #

Proxy_set_header Host $host:8080

Proxy_set_header X-Real-IP $remote_addr

Proxy_set_header X-Real-Port $remote_port

The Web server at the proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;# backend can obtain the user's real IP through X-Forwarded-For.

Proxy_pass http://backend;

Proxy_buffer_size 64kbot # sets the buffer size of the proxy server (nginx) for storing account information

Proxy_buffers 64 128kbot proxy buffers buffer

Proxy_busy_buffers_size 256kbot # buffer size under high load (proxy_buffers * 2)

Proxy_temp_file_write_size 256kbot # sets the cache folder size, which will be transferred from the upstream server

}

Location / nstatus {# set the address to view nginx status

Check_status

Access_log off

}

# error_page 404 / 404.html

# redirect server error pages to the static page / 50x.html

#

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

#}

}

Upstream backend1 {

Ip_hash

Server 50.50.50.16:8030

Server 50.50.50.13:8030

}

Server {

Listen 8090

Server_name WEBServer10414

Charset utf-8

Location / stsadmin-cm/ {

Index index.jsp index.htm index.html

Proxy_pass http://backend1/stsadmin-cm/;

Proxy_redirect default

Proxy_buffer_size 16k

Proxy_buffers 16 128k

Proxy_busy_buffers_size 256k

Proxy_temp_file_write_size 256k

}

Error_page 500 502 503 504 / 50x.html

Location = / 50x.html {

Root html

}

}

# 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

#}

#}

}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report