如果有异常的话,可以执行 nginx -t 命令, 这个时候可以看第一次返回的说明.
(base) ➜ html git:(master) nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: [emerg] open() "/opt/homebrew/Cellar/nginx/1.27.1/logs/nginx.pid" failed (2: No such file or directory)
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test failed
我们看到这里是说nginx的配置文件有问题, 而且是 nginx.pid 相关的配置导致异常, 然后再进一步分析是文件不存在导致. 解决方案: 1、创建相关丢失的文件,确保程序正常运行 2、移除 nginx.pid 相关的配置
补充说明: nginx 一般在启动的时候会去创建一些必须的文件,但是在权限过低的时候,创建文件的进程就会受阻;
之后我执行了2种解决方案, nginx -t 命令 的运行结果就正常了
(base) ➜ html git:(master) nginx -t
nginx: the configuration file /opt/homebrew/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /opt/homebrew/etc/nginx/nginx.conf test is successful
server {
listen 7788;
server_name modules.hht.test;
# add_header 'Access-Control-Expose-Headers' 'Authorization,X-Custom-Header';
# charset utf-8;invoice
# location / {
# root /Users/sysadmin/code/kerry_project/crm-admin-portal/crm_server/modules;
# index index.html index.htm;
# }
ssi on;
set $requestContextPath "/crm-admin-portal/";
# will be replaced with absolute path in nginx.js
root /Users/sysadmin/code/kerry_project/crm-admin-portal/crm_server;
# comment out on windows
# access_log /dev/stdout compact;
location ~* \.(eot|ttf|woff|woff2)$ {
add_header Access-Control-Allow-Origin *;
}
}
统一将 devServer.proxy 中的 /crm-admin-portal 和 /modules 中的target值改为'http://modules.hht.test:7788'
![[Pasted image 20240905142729.png]]
保持这样一条配置
127.0.0.1 modules.hht.test