什么时候该用这个 nginx.conf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 NGINX config 做 diff。
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/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_referer" '
'"$http_user_agent" "$http_x_forwarded_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;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
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;
location = /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_certificate "/etc/pki/nginx/server.crt";
# ssl_certificate_key "/etc/pki/nginx/private/server.key";
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
# ssl_prefer_server_ciphers on;
#
# # Load configuration files for the default server block.
# include /etc/nginx/default.d/*.conf;
#
# location / {
# }
#
# error_page 404 /404.html;
# location = /40x.html {
# }
#
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# }
# }
}
curl https://exampleconfig.com/api/v1/config/original/1284e1186e5e8dd7dbfb4ffb7b808e6f?hint=nginx.conf
wget -O nginx.conf https://exampleconfig.com/api/v1/config/original/1284e1186e5e8dd7dbfb4ffb7b808e6f?hint=nginx.conf
<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/1284e1186e5e8dd7dbfb4ffb7b808e6f?hint=nginx.conf' /><config><app>NGINX</app><os>Red Hat Enterprise Linux 8 (Ootpa)</os><location>/etc/nginx/nginx.conf</location><lines>90</lines><md5>1284e1186e5e8dd7dbfb4ffb7b808e6f</md5><sha256>1ada00e3d90b85ffb4590e1aab28084dd4a6cf7cdc9312e1941cd5b89aef81f0</sha256></config></prompt>
粘贴到 Claude、ChatGPT 或任何 AI 助手里。
sudo apk add nginx
sudo apt update && sudo apt install nginx
sudo yum install nginx
sudo apt update && sudo apt install nginx
什么时候该用这个 nginx.conf?
用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 NGINX config 做 diff。
怎么恢复 NGINX 的默认配置?
下载文件,把 /etc/nginx/nginx.conf 里的当前配置备份好,替换掉,然后 reload 或 restart NGINX。
nginx.conf 适合直接上生产吗?
这是 Red Hat Enterprise Linux 8 (Ootpa) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。
和其他 OS 版本有什么不同?
默认值会随发行版和版本变化,这份对应 Red Hat Enterprise Linux 8 (Ootpa)。
我可以用它来排查 NGINX 吗?
可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。