Appearance
服务器安装 Nginx
更新软件包列表
bashsudo apt update安装 Nginx
bashsudo apt install nginx启动 Nginx
bashsudo systemctl start nginx查看 Nginx 状态
bashsudo systemctl status nginx设置 Nginx 开机自启
bashsudo systemctl enable nginx创建配置文件
/etc/nginx/conf.d/eams4test.conf
txt
server {
listen 7601;
server_name 39.104.15.113;
location / {
root /data/eams4test/pc;
index index.html;
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_vary on;
}
location /uni {
alias /data/eams4test/uni;
index index.html;
gzip on;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/x-javascript text/css application/xml application/javascript;
gzip_vary on;
}
location /api {
proxy_pass http://localhost:6601/api;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_intercept_errors on;
client_max_body_size 50M;
}
location /api/websocket/upgrade {
proxy_pass http://localhost:6601/api/websocket/upgrade;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_intercept_errors on;
client_max_body_size 50M;
}
location /graphql {
proxy_pass http://localhost:6601/graphql;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_intercept_errors on;
client_max_body_size 50M;
}
}- 执行
sudo nginx -s reload重新加载Nginx配置文件 - 其中, 假设
.env.test中的server_port为6601, 对外提供的端口为7601
同理, 正式库则创建配置文件
/etc/nginx/conf.d/eams4prod.conf- 配置文件里面的
eams4test改为eams4prod, 端口号改为正式库配置文件.env.prod中的server_port
- 配置文件里面的