user root;
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;
# gzip on;
# gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
# 负载均衡
# upstream mysite.com {
# server localhost:8081;
# server localhost:8082;
# server localhost:8083;
# server localhost:8084;
# server localhost:8085;
# hash $request_uri;
# }
server {
listen 8080;
server_name localhost;
# hash mode
location / {
root /srv/;
index index.html;
}
# history mode
# location / {
# root /srv/;
# try_files $uri $uri/ /index.html;
# }
# api proxy
# location ^~ /api/ { # 注意末尾的"/"
# proxy_pass http://mysite.com/; # 注意末尾的"/"
# }
# socket proxy
# location ^~ /socket/ {
# proxy_pass http://mysite.com/socket/;
# proxy_http_version 1.1;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# }
}
# 负载均衡
# server {
# listen 8081;
# server_name localhost;
# location / {
# proxy_pass http://ip1.com;
# }
# }
# server {
# listen 8082;
# server_name localhost;
# location / {
# proxy_pass http://ip2.com;
# }
# }
# 示例二
server {
listen 8080;
root /home/service/app/xxx/dist;
location ~ .*(\.html|remoteEntry\.js) {
add_header Cache-Control no-cache;
}
location / {
expires max;
try_files $uri /index.html;
}
gzip on;
gzip_types text/plain text/css text/xml application/wasm application/javascript application/rss+xml application/atom+xml image/svg+xml;
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。