NGINX /etc/nginx/sites-available/default

原始 📋 Debian 9 (Stretch) 91 行

详情

大小
91 行
MD5
9b030ecaaccde110ce6ed49d2571f5b7
SHA256
e27fe6413217434eafda68bc95b2eacf38f8cb3d7b7f2011964ddb039ef35ebc
/etc/nginx/sites-available/default
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
	listen 80 default_server;
	listen [::]:80 default_server;

	# SSL configuration
	#
	# listen 443 ssl default_server;
	# listen [::]:443 ssl default_server;
	#
	# Note: You should disable gzip for SSL traffic.
	# See: https://bugs.debian.org/773332
	#
	# Read up on ssl_ciphers to ensure a secure configuration.
	# See: https://bugs.debian.org/765782
	#
	# Self signed certs generated by the ssl-cert package
	# Don't use them in a production server!
	#
	# include snippets/snakeoil.conf;

	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.html index.htm index.nginx-debian.html;

	server_name _;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
	}

	# pass PHP scripts to FastCGI server
	#
	#location ~ \.php$ {
	#	include snippets/fastcgi-php.conf;
	#
	#	# With php-fpm (or other unix sockets):
	#	fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
	#	# With php-cgi (or other tcp sockets):
	#	fastcgi_pass 127.0.0.1:9000;
	#}

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


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#	listen 80;
#	listen [::]:80;
#
#	server_name example.com;
#
#	root /var/www/example.com;
#	index index.html;
#
#	location / {
#		try_files $uri $uri/ =404;
#	}
#}

复制粘贴

curl:
curl https://exampleconfig.com/api/v1/config/original/9b030ecaaccde110ce6ed49d2571f5b7?hint=default
wget:
wget -O default https://exampleconfig.com/api/v1/config/original/9b030ecaaccde110ce6ed49d2571f5b7?hint=default

给 AI Agent 用

<prompt><role>DevOps agent</role><source url='https://exampleconfig.com/api/v1/config/original/9b030ecaaccde110ce6ed49d2571f5b7?hint=default' /><config><app>NGINX</app><os>Debian 9 (Stretch)</os><location>/etc/nginx/sites-available/default</location><lines>91</lines><md5>9b030ecaaccde110ce6ed49d2571f5b7</md5><sha256>e27fe6413217434eafda68bc95b2eacf38f8cb3d7b7f2011964ddb039ef35ebc</sha256></config></prompt>

粘贴到 Claude、ChatGPT 或任何 AI 助手里。

安装 NGINX

Alpine Linux

sudo apk add nginx

Debian

sudo apt update && sudo apt install nginx

Red Hat Enterprise Linux

sudo yum install nginx

Ubuntu

sudo apt update && sudo apt install nginx

文件位置

文件路径
/etc/nginx/sites-available/default
目录
/etc/nginx/sites-available/
用途
系统级配置目录
说明
/etc/ 里的文件是系统级配置,影响所有用户。

FAQ

什么时候该用这个 default?

用来恢复缺失的默认文件、确认发行版本带了什么,或拿你的 NGINX config 做 diff。

怎么恢复 NGINX 的默认配置?

下载文件,把 /etc/nginx/sites-available/default 里的当前配置备份好,替换掉,然后 reload 或 restart NGINX。

default 适合直接上生产吗?

这是 Debian 9 (Stretch) 的厂商默认配置,只能当基线。上生产前请检查安全和性能设置。

和其他 OS 版本有什么不同?

默认值会随发行版和版本变化,这份对应 Debian 9 (Stretch)。

我可以用它来排查 NGINX 吗?

可以。和你的配置做 diff 找出漂移,然后只恢复需要的段落。