docker部署vue(nginx)
server {
listen 80; # 监听端口,默认80,与后面运行容器时的端口映射相对应
listen [::]:80;
server_name localhost;
#access_log /var/log/nginx/ main;
location / {
root /usr/share/nginx/html; # vue项目打包后dist里的文件所存放的目录
index ;
}
# 后端反向代理配置
location /api {
# 相对应把vue中以api为开头的请求路径指向http://ip:8088/
proxy_pass http://ip:8088/;
}
#error_page 404 /;
# redirect server error pages to the static page /
#
error_page 500 502 503 504 /;
location = / {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index ;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}