代码拉取完成,页面将自动刷新
##
# 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 begin
# http 重定向到 https
return 301 https://$host$request_uri;
}
server {
# SSL configuration
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
ssl_certificate /root/ssl/chenxiaosong.com.pem;
ssl_certificate_key /root/ssl/chenxiaosong.com.key;
# ssl end
#
# 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 /home/sonvhi/chenxiaosong/www/html;
root /var/www/html;
autoindex on; # 打开目录浏览功能
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
error_page 404 = /default-location;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ $uri.html =404;
}
location = /default-location {
# 设置默认地址的配置,使用302临时重定向
return 302 /;
}
# TODO: 放在location /passwd后面不生效,为什么呢,为什么呢
location /private/kylinos {
# 目录浏览时字符集为 UTF-8
add_header Content-Type "text/html; charset=UTF-8";
}
location /passwd {
auth_basic "passwd access"; # 提示文本,可以随意设置
auth_basic_user_file /etc/nginx/.htpasswd; # 密码文件的路径
# TODO: 禁用缓存
}
# 解决txt文件乱码的问题
location ~* \.txt$ {
add_header Content-Type "text/plain; charset=UTF-8";
}
# 404 begin
# 执行命令 bash src/blog-web/create-nginx-404.sh
# 在这里插入网页重定向的内容
# 404 end
# 网页重定向
# location /tmp/btrfs-forced-readonly-log.txt {
# # permanent(永久) 或 redirect(临时), 默认 redirect
# rewrite ^/tmp/btrfs-forced-readonly-log.txt$ https://gitee.com/chenxiaosonggitee/tmp/blob/master/btrfs/btrfs-forced-readonly-log.txt;
# }
# 转发
# location /code-server/ { # 注意code-server后面有斜杠
# # 端口后面也要有斜杠
# proxy_pass http://127.0.0.1:8888/;
# # 不指定默认用1.0
# proxy_http_version 1.1;
# # 将客户端请求头中的 Upgrade 字段的值传递给后端服务器,常用于在进行 WebSocket 连接时,告知后端服务器进行协议升级
# proxy_set_header Upgrade $http_upgrade;
# # 设置了请求头中的 Connection 字段的值为 "upgrade",它告诉后端服务器要升级连接协议
# proxy_set_header Connection "upgrade";
# # 设置了请求头中的 Host 字段的值为客户端请求中的 Host 值,它确保将客户端请求中的原始主机头信息传递给后端服务器
# proxy_set_header Host $host; # 如果是vue用npm run serve启动的服务,$host要替换成ip
# }
# location /guarantee/ {
# proxy_pass http://127.0.0.1:8080/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_set_header Host 8.217.113.83; # 如果是vue用npm run serve启动的服务,$host要替换成ip
# }
# location /guarantee-api/ {
# proxy_pass http://127.0.0.1:5001/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_set_header Host $host;
# }
# 只允许本机访问
# location /localhost/ {
# allow 127.0.0.1;
# deny all;
# }
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/run/php/php7.4-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;
# }
#}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。