1 # 指定Nginx使用的工作进程数,这里设置为1,生产环境中应根据CPU核心数调整以提高性能。
2 worker_processes 1;
3
4 events {
5 # 设置每个工作进程可以同时处理的连接数,这里是1024。
6 worker_connections 1024;
7 }
8
9 http {
10 # 包含MIME类型文件,用于识别文件类型。
11 include mime.types;
12 # 默认文件类型,当请求的资源没有明确类型时使用。
13 default_type application/octet-stream;
14
15 # 开启高效文件传输模式,适合大文件传输。
16 sendfile on;
17
18 # 设置长连接超时时间,单位为秒。
19 keepalive_timeout 65;
20
21 # 定义一个服务器块,配置HTTP服务的基本信息。
22 server {
23 # 监听的端口。
24 listen 80;
25 # 服务器的域名或IP地址。
26 server_name 47.108.117.229;
27
28 # 配置根目录和默认首页。
29 location / {
30 root /usr/local/nginx/html/dist;
31 index index.html index.htm;
32 }
33
34 # API请求代理设置,将请求转发到指定的后端服务器。
35 location /api/ {
36 proxy_pass http://47.108.117.229:9995;
37 proxy_set_header Upgrade $http_upgrade;
38 proxy_set_header Connection "upgrade";
39 }
40
41 # 错误页面配置,当遇到特定错误代码时显示的页面。
42 error_page 500 502 503 504 /50x.html;
43 # 错误页面的位置。
44 location = /50x.html {
45 root html;
46 }
47 }
48 }