配置文件地址 #nginx/conf/con.d/default.conf
server {
listen 80;
server_name 0.0.0.0; #外網ip
client_max_body_size 20m;
#charset koi8-r;
access_log /var/log/nginx/access.log main;
location / { # 攔截請求靜態頁面地址/home/dist下
root /home/dist;
index index.html index.htm login.html;
add_header Access-Control-Allow-Origin *;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
location ^~/api/ {
proxy_pass http://0.0.0.0:8080/; # 攔截所有"/api/"的http請求轉發到內網ip
}
}
react和vue項目使用nginx部署其中一種配置方法