vuex项目使用 打包
npm run build:prod
目录结构为:
nginx.conf配置为:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
root /usr/share/nginx/html/ruoyiadmin/dist;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /prod-api/ {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://1.117.***.7:8080/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
default.conf配置为:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html/ruoyiadmin/dist;
index index.html;
}
#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 ~ \.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 index.php;
# 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;
#}
}
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9cfee0e78b33 nginx "/docker-entrypoint.…" 15 minutes ago Up 15 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp mynginx
5bfc44e79ab1 ruoyi:v1.0.0 "java -jar /ruoyi-ad…" 2 hours ago Up 2 hours 0.0.0.0:8020->8020/tcp, :::8020->8020/tcp jovial_lehmann
85de01dfc5ba mysql:5.7 "docker-entrypoint.s…" 7 hours ago Up 6 hours 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp, 33060/tcp mysql
7a32f2a9df94 redis "docker-entrypoint.s…" 24 hours ago Up 7 hours 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp redis
cdfb89e21068 kdvolder/jdk8 "/bin/sh -c /bin/bash" 24 hours ago Up 7 hours jdk1.8
浏览器访问报错