Nginx配置
nginx.conf文件:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
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"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8081;
server_name example.com;
# 设置根目录指向你的前端项目所在目录
root D:/html;
# 默认返回 index.html 文件
index index.html;
# 提供静态资源
location / {
try_files $uri /index.html; # 对于 SPA,所有请求都会指向 index.html
}
# 如果访问图片等资源,直接提供相应的文件
location /File/ {
alias D:/File/; # 使用 alias 来映射 /images/ 请求到 D:/images/ 目录
try_files $uri =404; # 文件不存在时返回 404
}
}
# 新增的H5服务配置
server {
listen 8082;
server_name 192.168.1.62;
location / {
root D:/h5;
index index.html;
try_files $uri $uri/ /h5/index.html;
}
# 如果需要处理API请求或其他请求,可以在这里添加额外的location块
# location /api {
# proxy_pass http://backend_server;
# }
}
}

浙公网安备 33010602011771号