vue项目通过xginx接口代理
作者:
0说 | 来源:发表于
2022-01-25 15:51 被阅读0次
#user nobody;
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;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
# vue项目如果不想用proxy代理可通过nginx代理
server {
listen 8010; // 这里不能跟vue项目同一个端口 否则是没办法启起来,报端口被占用
server_name localhost;
#charset koi8-r;
access_log logs/host.access.log;
# 上面的监控会被转发到下面的地址 这里是vue的项目地址
location / {
proxy_pass http://localhost:8002;
}
# 上面转发到我们项目的地址后 这里 /api会被转发到 http://localhost:3800/api 这里的地址访问接口地址
location /api{
proxy_pass http://localhost:3800/api;
proxy_redirect off;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
本文标题:vue项目通过xginx接口代理
本文链接:https://www.haomeiwen.com/subject/uuvwhrtx.html
网友评论