[GH-ISSUE #750] 非常喜欢nginx ui,但是折腾了几天,还是以失败而告终。。。。 #7515

Closed
opened 2026-03-12 21:26:45 +03:00 by kerem · 15 comments
Owner

Originally created by @zjqwll on GitHub (Nov 22, 2024).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/750

1732261761324
虽然之前一键安装程序能起来,但是没办法读取配置文件,经过测试,发现配置这句话后include /usr/local/soft/nginx/conf/.conf;
就会报各种问题,按照提示注释后,又会报下一句,反正没完没了。include /usr/local/soft/nginx/conf/
.conf;后,一切都正常,眼睛都毛冒金花儿了。
网上也没找到资料,也是严格按照官网https://nginxui.com/zh_CN/guide/getting-started.html这么操作的,但是还是失败

Originally created by @zjqwll on GitHub (Nov 22, 2024). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/750 ![1732261761324](https://github.com/user-attachments/assets/331b6715-1ad9-436b-b64d-8196a401a37b) 虽然之前一键安装程序能起来,但是没办法读取配置文件,经过测试,发现配置这句话后include /usr/local/soft/nginx/conf/*.conf; 就会报各种问题,按照提示注释后,又会报下一句,反正没完没了。include /usr/local/soft/nginx/conf/*.conf;后,一切都正常,眼睛都毛冒金花儿了。 网上也没找到资料,也是严格按照官网https://nginxui.com/zh_CN/guide/getting-started.html这么操作的,但是还是失败。
kerem closed this issue 2026-03-12 21:26:50 +03:00
Author
Owner

@jearton commented on GitHub (Nov 22, 2024):

在线不是可以修改配置文件么,我用得都好好的,你是不是不懂nginx啊

<!-- gh-comment-id:2493173213 --> @jearton commented on GitHub (Nov 22, 2024): 在线不是可以修改配置文件么,我用得都好好的,你是不是不懂nginx啊
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

在线不是可以修改配置文件么,我用得都好好的,你是不是不懂nginx啊

在线修改的前提是配置好,我现在配置还没成功,就没办法读取配置文件。现在centos中的nginx只要加了include /usr/local/soft/nginx/conf/.conf;就报错

<!-- gh-comment-id:2493188473 --> @zjqwll commented on GitHub (Nov 22, 2024): > 在线不是可以修改配置文件么,我用得都好好的,你是不是不懂nginx啊 在线修改的前提是配置好,我现在配置还没成功,就没办法读取配置文件。现在centos中的nginx只要加了include /usr/local/soft/nginx/conf/.conf;就报错
Author
Owner

@0xJacky commented on GitHub (Nov 22, 2024):

/usr/local/soft/nginx/conf 里面放的什么配置文件,脱敏之后贴出来看看

<!-- gh-comment-id:2493194643 --> @0xJacky commented on GitHub (Nov 22, 2024): /usr/local/soft/nginx/conf 里面放的什么配置文件,脱敏之后贴出来看看
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

/usr/local/soft/nginx/conf 里面放的什么配置文件,脱敏之后贴出来看看

#配置用户或者组,默认为nobody nobody
#user nginx;
#user root;
user nobody;

#允许的工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU
worker_processes auto;
#worker_processes 8;

#设置worker进程的最大打开文件数
worker_rlimit_nofile 65535;

#错误日志存放路径配置和日志级别
error_log /usr/local/soft/nginx/logs/error.log crit;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#指定nginx进程运行文件存放地址
pid /usr/local/soft/nginx/logs/nginx.pid;
#pid logs/nginx.pid;

events {
#每个进程最大连接数(最大连接=连接数x进程数)
worker_connections 1024;

#Linux下打开提高性能,事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
use epoll;

#设置一个进程是否同时接受多个网络连接,默认为off
multi_accept on;

#设置网路连接序列化,防止惊群现象发生,默认为on
accept_mutex on;

}

#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#文件扩展名与文件类型映射表
include mime.types;

default_type  application/octet-stream;

#日志格式化
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for';

#日志编码
#charset gb2312;

#access日志路径
access_log  /usr/local/soft/nginx/logs/access.log  main;

server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;

#允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
sendfile on;
tcp_nopush on;
#keepalive_timeout  0;
keepalive_timeout  65;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

#开启gzip压缩
gzip on;
#设置允许压缩的页面最小字节数,不压缩临界值,大于1K的才压缩,一般不用改
gzip_min_length 1k;
#用来存储 gzip 的压缩结果,压缩缓冲区
gzip_buffers 16 64K;
#识别HTTP协议压缩版本(默认1.1,前端如果是squid2.5请使用1.0)
gzip_http_version 1.1;
#压缩比级别,1-10,1 压缩比最小但最快,而 9 相反,数字越大压缩的越好,时间也越长.
gzip_comp_level 2;
#指定压缩的文件类型
gzip_types gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/x-javascript; 
# 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩
gzip_proxied any;
#跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding"
gzip_vary on;
#IE6对Gzip不怎么友好,不给它Gzip了
gzip_disable "MSIE [1-6]\.";

#limit_zone crawler $binary_remote_addr 10m;

##########################默认配置###############################
#默认配置,方便测试
server {
    listen       80;
    server_name  localhost;
    #charset koi8-r;
    #access_log  logs/host.access.log  main;

    location / {
	    #定义服务器的默认网站根目录位置
        root   html;
        index  index.html index.htm;
    }
	
    #error_page  404              /404.html;
	
    #使用error_page指令来将服务器错误页面重定向到一个静态页面,比如/50x.html
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
}

##########################Nginx UI配置###############################
#Nginx UI配置-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。
server {
    listen          80;
    listen          [::]:80;
    server_name     nginxui.baidu.com;
    rewrite ^(.*)$  https://$host$1 permanent;
}

#map 指令,用于根据 $http_upgrade 变量设置 $connection_upgrade 变量的值,该变量用于 WebSocket 连接。
map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

#监听 443 端口(HTTPS)和IPv6 地址,以及 HTTP/2 协议。配置ssl证书。
server {
    listen  443       ssl;
    listen  [::]:443  ssl;
    server_name        nginxui.baidu.com;

    #貌似不支持,可能要下载nginx最新版源码重新编译
    #http2   on;
	
	#配置证书
    ssl_certificate     /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem;
    ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key;

    #包含代理设置,将请求转发到本地端口9000。代理设置还包括一些用于正确处理转发请求的标头,如 Host、X-Real-IP、X-Forwarded-For、X-Forwarded-Proto、Upgrade 和 Connection。  
    location / {
        proxy_set_header    Host                $host;
        proxy_set_header    X-Real-IP           $remote_addr;
        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
        proxy_set_header    X-Forwarded-Proto   $scheme;
		
		#以下3行解决wss和ws的通信问题
        proxy_http_version  1.1;
        proxy_set_header    Upgrade             $http_upgrade;
        proxy_set_header    Connection          $connection_upgrade;
		
        proxy_pass          http://127.0.0.1:9000/;
     }
 }
 
##########################博客测试API接口配置###############################
#博客测试API-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。
server {
    listen          80;
    listen          [::]:80;
	server_name testapi.baidu.com;

	#将所有HTTP请求通过rewrite指令重定向到HTTPS。
	rewrite ^(.*)$ https://$host$1 permanent;
}

#博客测试-API服务端负载均衡配置
upstream baidu_api_server {
	#weight=数字来指定,数字越大,表明请求到的机会越大。
	#max_fails=数字来指定,设定Nginx与服务器通信的尝试失败的次数。
	#fail_timeout=秒数,在下一个fail_timeout时间段,服务器不会再被尝试。
	#backup 标记为备份服务器
	#down 标记为暂时移除
	server 127.0.0.1:9080 weight=9 max_fails=2 fail_timeout=10s;
	server 127.0.0.1:48081 weight=8 max_fails=2 fail_timeout=10s backup;
}

#博客测试-API服务端https配置
server {
    listen  443       ssl;
    listen  [::]:443  ssl;
	server_name testapi.baidu.com;
	charset utf-8;

    #貌似不支持,可能要下载nginx最新版源码重新编译
    #http2   on;
	
	#配置证书
    ssl_certificate     /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem;
    ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key;
	
	#ssl_session_cache    shared:SSL:1m;
	ssl_session_timeout 5m;
	#表示使用的加密套件的类型。
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	#表示使用的TLS协议的类型。
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;

	#默认请求
	location / {
		#proxy_connect_timeout      60;
		proxy_send_timeout 60;
		proxy_read_timeout 60;
		proxy_buffer_size 4k;
		proxy_buffers 4 32K;
		proxy_busy_buffers_size 64k;
		#proxy_temp_file_write_size 1m;

		proxy_set_header Host $http_host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header REMOTE-HOST $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

		#以下3行解决wss和ws的通信问题
		proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1; 
		
		#proxy_redirect http:// https://;
		   
		#通过负载均衡,转向代理的地址
		proxy_pass http://baidu_api_server;
	}

	#文件服务器,目前我们使用oss,暂时不需要自己搭建文件服务器
	#location /profile/ {
		#方式一:指向地址
		#proxy_pass http://127.0.0.1:9080/profile/;
		#方式二:指向目录,对应后台`application.yml`中的`profile`配置
		#alias /usr/local/soft/server/upload/baidu-control-service/;
	#}

	#定义错误提示页面
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root html;
		index index.html index.htm;
	}
}

##########################博客测试file oss域名配置###############################
#博客测试file oss域名-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。
server {
    listen          80;
    listen          [::]:80;
	server_name file.baidu.com;

	#将所有HTTP请求通过rewrite指令重定向到HTTPS。
	rewrite ^(.*)$ https://$host$1 permanent;
}

#博客测试-file oss域名服务端https配置
server {
    listen  443       ssl;
    listen  [::]:443  ssl;
	server_name file.baidu.com;
	charset utf-8;

    #貌似不支持,可能要下载nginx最新版源码重新编译
    #http2   on;
	
	#配置证书
    ssl_certificate     /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem;
    ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key;
	
	#ssl_session_cache    shared:SSL:1m;
	ssl_session_timeout 5m;
	#表示使用的加密套件的类型。
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	#表示使用的TLS协议的类型。
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;

	#默认请求
	location / {
		#proxy_connect_timeout      60;
		proxy_send_timeout 60;
		proxy_read_timeout 60;
		proxy_buffer_size 4k;
		proxy_buffers 4 32K;
		proxy_busy_buffers_size 64k;
		#proxy_temp_file_write_size 1m;

		proxy_set_header Host $http_host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header REMOTE-HOST $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		
		#proxy_redirect http:// https://;
		   
		#通过负载均衡,转向代理的地址
		proxy_pass http://baidu-bucket.oss-cn-nanjin.aliyuncs.com;
	}
}

##########################博客测试-管理平台web配置###############################
#博客测试运管平台web-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。
server {
    listen          80;
    listen          [::]:80;
	server_name manage.baidu.com;

	#将所有HTTP请求通过rewrite指令重定向到HTTPS。
	rewrite ^(.*)$ https://$host$1 permanent;
}

#博客测试-运营管理web端 https配置
server {
    listen  443       ssl;
    listen  [::]:443  ssl;
	server_name manage.baidu.com;
	charset utf-8;

    #貌似不支持,可能要下载nginx最新版源码重新编译
    #http2   on;
	
	#配置证书
    ssl_certificate     /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem;
    ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key;

    #ssl_session_cache    shared:SSL:1m;
	ssl_session_timeout 5m;
	#表示使用的加密套件的类型。
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	#表示使用的TLS协议的类型。
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;

	#默认请求
	location / {
		#解决页面刷新404问题
		try_files $uri $uri/ /index.html;

		#定义服务器的默认网站根目录位置
		root /usr/local/soft/service/web/manage;

		#定义首页索引文件的名称
		index index.html index.htm;

		#访问Http资源
		add_header Content-Security-Policy upgrade-insecure-requests;
	}

	#定义错误提示页面
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root html;
	}
}

##########################博客测试-小程序web配置###############################
#博客测试小程序web-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。
server {
    listen          80;
    listen          [::]:80;
	server_name wx.baidu.com;

	#将所有HTTP请求通过rewrite指令重定向到HTTPS。
	rewrite ^(.*)$ https://$host$1 permanent;
}

#博客测试-运营管理web端 https配置
server {
    listen  443       ssl;
    listen  [::]:443  ssl;
	server_name wx.baidu.com;
	charset utf-8;

    #貌似不支持,可能要下载nginx最新版源码重新编译
    #http2   on;
	
	#配置证书
    ssl_certificate     /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem;
    ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key;

    #ssl_session_cache    shared:SSL:1m;
	ssl_session_timeout 5m;
	#表示使用的加密套件的类型。
	ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
	#表示使用的TLS协议的类型。
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_prefer_server_ciphers on;

	#默认请求
	location / {
		#解决页面刷新404问题
		try_files $uri $uri/ /index.html;

		#定义服务器的默认网站根目录位置
		root /usr/local/soft/service/web/applet;

		#定义首页索引文件的名称
		index index.html index.htm;

		#访问Http资源
		add_header Content-Security-Policy upgrade-insecure-requests;
	}

	#定义错误提示页面
	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
		root html;
	}
}

}

<!-- gh-comment-id:2493213647 --> @zjqwll commented on GitHub (Nov 22, 2024): > /usr/local/soft/nginx/conf 里面放的什么配置文件,脱敏之后贴出来看看 #配置用户或者组,默认为nobody nobody #user nginx; #user root; user nobody; #允许的工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU worker_processes auto; #worker_processes 8; #设置worker进程的最大打开文件数 worker_rlimit_nofile 65535; #错误日志存放路径配置和日志级别 error_log /usr/local/soft/nginx/logs/error.log crit; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #指定nginx进程运行文件存放地址 pid /usr/local/soft/nginx/logs/nginx.pid; #pid logs/nginx.pid; events { #每个进程最大连接数(最大连接=连接数x进程数) worker_connections 1024; #Linux下打开提高性能,事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport use epoll; #设置一个进程是否同时接受多个网络连接,默认为off multi_accept on; #设置网路连接序列化,防止惊群现象发生,默认为on accept_mutex on; } #设定http服务器,利用它的反向代理功能提供负载均衡支持 http { #文件扩展名与文件类型映射表 include mime.types; default_type application/octet-stream; #日志格式化 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; #日志编码 #charset gb2312; #access日志路径 access_log /usr/local/soft/nginx/logs/access.log main; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; #允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。 sendfile on; tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; #开启gzip压缩 gzip on; #设置允许压缩的页面最小字节数,不压缩临界值,大于1K的才压缩,一般不用改 gzip_min_length 1k; #用来存储 gzip 的压缩结果,压缩缓冲区 gzip_buffers 16 64K; #识别HTTP协议压缩版本(默认1.1,前端如果是squid2.5请使用1.0) gzip_http_version 1.1; #压缩比级别,1-10,1 压缩比最小但最快,而 9 相反,数字越大压缩的越好,时间也越长. gzip_comp_level 2; #指定压缩的文件类型 gzip_types gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript application/x-javascript; # 无论后端服务器的 headers 头返回什么信息,都无条件启用压缩 gzip_proxied any; #跟Squid等缓存服务有关,on的话会在Header里增加"Vary: Accept-Encoding" gzip_vary on; #IE6对Gzip不怎么友好,不给它Gzip了 gzip_disable "MSIE [1-6]\."; #limit_zone crawler $binary_remote_addr 10m; ##########################默认配置############################### #默认配置,方便测试 server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #定义服务器的默认网站根目录位置 root html; index index.html index.htm; } #error_page 404 /404.html; #使用error_page指令来将服务器错误页面重定向到一个静态页面,比如/50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } ##########################Nginx UI配置############################### #Nginx UI配置-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。 server { listen 80; listen [::]:80; server_name nginxui.baidu.com; rewrite ^(.*)$ https://$host$1 permanent; } #map 指令,用于根据 $http_upgrade 变量设置 $connection_upgrade 变量的值,该变量用于 WebSocket 连接。 map $http_upgrade $connection_upgrade { default upgrade; '' close; } #监听 443 端口(HTTPS)和IPv6 地址,以及 HTTP/2 协议。配置ssl证书。 server { listen 443 ssl; listen [::]:443 ssl; server_name nginxui.baidu.com; #貌似不支持,可能要下载nginx最新版源码重新编译 #http2 on; #配置证书 ssl_certificate /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem; ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key; #包含代理设置,将请求转发到本地端口9000。代理设置还包括一些用于正确处理转发请求的标头,如 Host、X-Real-IP、X-Forwarded-For、X-Forwarded-Proto、Upgrade 和 Connection。 location / { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; #以下3行解决wss和ws的通信问题 proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_pass http://127.0.0.1:9000/; } } ##########################博客测试API接口配置############################### #博客测试API-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。 server { listen 80; listen [::]:80; server_name testapi.baidu.com; #将所有HTTP请求通过rewrite指令重定向到HTTPS。 rewrite ^(.*)$ https://$host$1 permanent; } #博客测试-API服务端负载均衡配置 upstream baidu_api_server { #weight=数字来指定,数字越大,表明请求到的机会越大。 #max_fails=数字来指定,设定Nginx与服务器通信的尝试失败的次数。 #fail_timeout=秒数,在下一个fail_timeout时间段,服务器不会再被尝试。 #backup 标记为备份服务器 #down 标记为暂时移除 server 127.0.0.1:9080 weight=9 max_fails=2 fail_timeout=10s; server 127.0.0.1:48081 weight=8 max_fails=2 fail_timeout=10s backup; } #博客测试-API服务端https配置 server { listen 443 ssl; listen [::]:443 ssl; server_name testapi.baidu.com; charset utf-8; #貌似不支持,可能要下载nginx最新版源码重新编译 #http2 on; #配置证书 ssl_certificate /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem; ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key; #ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #表示使用的加密套件的类型。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #表示使用的TLS协议的类型。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #默认请求 location / { #proxy_connect_timeout 60; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffer_size 4k; proxy_buffers 4 32K; proxy_busy_buffers_size 64k; #proxy_temp_file_write_size 1m; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #以下3行解决wss和ws的通信问题 proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_http_version 1.1; #proxy_redirect http:// https://; #通过负载均衡,转向代理的地址 proxy_pass http://baidu_api_server; } #文件服务器,目前我们使用oss,暂时不需要自己搭建文件服务器 #location /profile/ { #方式一:指向地址 #proxy_pass http://127.0.0.1:9080/profile/; #方式二:指向目录,对应后台`application.yml`中的`profile`配置 #alias /usr/local/soft/server/upload/baidu-control-service/; #} #定义错误提示页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root html; index index.html index.htm; } } ##########################博客测试file oss域名配置############################### #博客测试file oss域名-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。 server { listen 80; listen [::]:80; server_name file.baidu.com; #将所有HTTP请求通过rewrite指令重定向到HTTPS。 rewrite ^(.*)$ https://$host$1 permanent; } #博客测试-file oss域名服务端https配置 server { listen 443 ssl; listen [::]:443 ssl; server_name file.baidu.com; charset utf-8; #貌似不支持,可能要下载nginx最新版源码重新编译 #http2 on; #配置证书 ssl_certificate /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem; ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key; #ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #表示使用的加密套件的类型。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #表示使用的TLS协议的类型。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #默认请求 location / { #proxy_connect_timeout 60; proxy_send_timeout 60; proxy_read_timeout 60; proxy_buffer_size 4k; proxy_buffers 4 32K; proxy_busy_buffers_size 64k; #proxy_temp_file_write_size 1m; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #proxy_redirect http:// https://; #通过负载均衡,转向代理的地址 proxy_pass http://baidu-bucket.oss-cn-nanjin.aliyuncs.com; } } ##########################博客测试-管理平台web配置############################### #博客测试运管平台web-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。 server { listen 80; listen [::]:80; server_name manage.baidu.com; #将所有HTTP请求通过rewrite指令重定向到HTTPS。 rewrite ^(.*)$ https://$host$1 permanent; } #博客测试-运营管理web端 https配置 server { listen 443 ssl; listen [::]:443 ssl; server_name manage.baidu.com; charset utf-8; #貌似不支持,可能要下载nginx最新版源码重新编译 #http2 on; #配置证书 ssl_certificate /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem; ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key; #ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #表示使用的加密套件的类型。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #表示使用的TLS协议的类型。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #默认请求 location / { #解决页面刷新404问题 try_files $uri $uri/ /index.html; #定义服务器的默认网站根目录位置 root /usr/local/soft/service/web/manage; #定义首页索引文件的名称 index index.html index.htm; #访问Http资源 add_header Content-Security-Policy upgrade-insecure-requests; } #定义错误提示页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } ##########################博客测试-小程序web配置############################### #博客测试小程序web-侦听 80 端口(HTTP)和 IPv6 地址,将所有HTTP请求通过rewrite指令重定向到HTTPS。 server { listen 80; listen [::]:80; server_name wx.baidu.com; #将所有HTTP请求通过rewrite指令重定向到HTTPS。 rewrite ^(.*)$ https://$host$1 permanent; } #博客测试-运营管理web端 https配置 server { listen 443 ssl; listen [::]:443 ssl; server_name wx.baidu.com; charset utf-8; #貌似不支持,可能要下载nginx最新版源码重新编译 #http2 on; #配置证书 ssl_certificate /usr/local/soft/cert/baidu.com_1121071806/baidu.com_cert_chain.pem; ssl_certificate_key /usr/local/soft/cert/baidu.com_1121071806/baidu.com_key.key; #ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; #表示使用的加密套件的类型。 ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; #表示使用的TLS协议的类型。 ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; #默认请求 location / { #解决页面刷新404问题 try_files $uri $uri/ /index.html; #定义服务器的默认网站根目录位置 root /usr/local/soft/service/web/applet; #定义首页索引文件的名称 index index.html index.htm; #访问Http资源 add_header Content-Security-Policy upgrade-insecure-requests; } #定义错误提示页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
Author
Owner

@0xJacky commented on GitHub (Nov 22, 2024):

不对啊,为什么要在 nginx.conf 里 include /usr/local/soft/nginx/conf/.conf; 这不就循环引用了吗

<!-- gh-comment-id:2493309801 --> @0xJacky commented on GitHub (Nov 22, 2024): 不对啊,为什么要在 nginx.conf 里 include /usr/local/soft/nginx/conf/.conf; 这不就循环引用了吗
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

不对啊,为什么要在 nginx.conf 里 include /usr/local/soft/nginx/conf/.conf; 这不就循环引用了吗

1732268192253
这里面不是说要这么加的么

<!-- gh-comment-id:2493329012 --> @zjqwll commented on GitHub (Nov 22, 2024): > 不对啊,为什么要在 nginx.conf 里 include /usr/local/soft/nginx/conf/.conf; 这不就循环引用了吗 ![1732268192253](https://github.com/user-attachments/assets/89d6cee5-f865-4d18-aefe-955dd2768975) 这里面不是说要这么加的么
Author
Owner

@0xJacky commented on GitHub (Nov 22, 2024):

这个是参考示例,你要根据实际环境的配置情况,因地制宜。

<!-- gh-comment-id:2493330322 --> @0xJacky commented on GitHub (Nov 22, 2024): 这个是参考示例,你要根据实际环境的配置情况,因地制宜。
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

这个是参考示例,你要根据实际环境的配置情况,因地制宜。

我是centos,按这个说的话,我的确是应该配置的
我第一次使用一键安装后,服务起来了,但是nginx/sites-enabled下面没有内容

<!-- gh-comment-id:2493346158 --> @zjqwll commented on GitHub (Nov 22, 2024): > 这个是参考示例,你要根据实际环境的配置情况,因地制宜。 我是centos,按这个说的话,我的确是应该配置的 我第一次使用一键安装后,服务起来了,但是nginx/sites-enabled下面没有内容
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

请注意,我们在文档中包含的是conf.d目录和sites-enabled目录下的*.conf文件,不知道为什么你为曲解成conf目录。.d后缀的文件夹一般是用于管理格式相同,目的一致的配置文件。此外我们也附上了 Debian 完整的配置文件给你参考,配置不要文档只看一半就按自己的理解写啊。

<!-- gh-comment-id:2493355961 --> @Hintay commented on GitHub (Nov 22, 2024): 请注意,我们在文档中包含的是`conf.d`目录和`sites-enabled`目录下的`*.conf`文件,不知道为什么你为曲解成`conf`目录。`.d`后缀的文件夹一般是用于管理格式相同,目的一致的配置文件。此外我们也附上了 Debian 完整的配置文件给你参考,配置不要文档只看一半就按自己的理解写啊。
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

请参考 Debian 的结构来修改你的配置目录后才可正常使用:
https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf

<!-- gh-comment-id:2493364641 --> @Hintay commented on GitHub (Nov 22, 2024): 请参考 Debian 的结构来修改你的配置目录后才可正常使用: https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

请参考 Debian 的结构来修改你的配置目录后才可正常使用: https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf

好的,谢谢哈。不过我看了https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf,感觉还是要配置那两句话,依然没看懂
include /etc/nginx/conf.d/.conf;
include /etc/nginx/sites-enabled/
;
我不知道我到底是要配还是不配置以上2句话。我没有conf.d

<!-- gh-comment-id:2493365166 --> @zjqwll commented on GitHub (Nov 22, 2024): > 请参考 Debian 的结构来修改你的配置目录后才可正常使用: https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf 好的,谢谢哈。不过我看了https://salsa.debian.org/nginx-team/nginx/-/blob/master/debian/conf/nginx.conf,感觉还是要配置那两句话,依然没看懂。 include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; 我不知道我到底是要配还是不配置以上2句话。我没有conf.d
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。

<!-- gh-comment-id:2493372065 --> @Hintay commented on GitHub (Nov 22, 2024): 前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。
是的,按这个提示,我就不需要配置include /etc/nginx/conf.d/.conf;的

<!-- gh-comment-id:2493373438 --> @zjqwll commented on GitHub (Nov 22, 2024): > 前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。 是的,按这个提示,我就不需要配置include /etc/nginx/conf.d/.conf;的
Author
Owner

@zjqwll commented on GitHub (Nov 22, 2024):

前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。

如果不需要配置include /etc/nginx/conf.d/.conf;,但是应该是需要配置include /usr/local/soft/nginx/sites-enabled/*;不然服务启动后,读取不到配置文件

<!-- gh-comment-id:2493381114 --> @zjqwll commented on GitHub (Nov 22, 2024): > 前面那个 issue 中提示不支持 user 指令的原因是重复包含了 nginx.conf 文件,导致第二个 user 指令在 http 块中。user 指令需要在最外层,而且只能有一个。 如果不需要配置include /etc/nginx/conf.d/.conf;,但是应该是需要配置include /usr/local/soft/nginx/sites-enabled/*;不然服务启动后,读取不到配置文件
Author
Owner

@Hintay commented on GitHub (Nov 22, 2024):

此外,你需要把以前写在 nginx.conf 中的 server 块除了最上面默认的块之外,都按 Server Name 分成单个文件放在 sites-available 目录中,这样 Nginx UI 才能对网站进行管理。

<!-- gh-comment-id:2493381354 --> @Hintay commented on GitHub (Nov 22, 2024): 此外,你需要把以前写在 nginx.conf 中的 server 块除了最上面默认的块之外,都按 Server Name 分成单个文件放在 sites-available 目录中,这样 Nginx UI 才能对网站进行管理。
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#7515
No description provided.