#user nobody;
worker_processes 2;
#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;
gzip on;
gzip_static on;
gzip_buffers 16 64k;
gzip_comp_level 5;
gzip_types text/plain application/javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png application/octet-stream;
# 项目1
server {
listen 8006;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
root html;
index index.html index.htm;
try_files $uri $uri/ /; #加上这一行
}
location /img {
proxy_pass http://xxx.xxx.xxx.xxx:xxxx/img;
}
location /sys {
proxy_pass http://xxx.xx.xxx.xxx:xxxx/sys;
}
}
# 项目2
server {
listen 8001;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Credentials' 'true';
root html;
index index.html index.html;
try_files $uri $uri/ /index.html; #加上这一行
}
location /default/ {
proxy_pass http://xxx.xxx.xxx.xxx:1111/;
proxy_cookie_path / /default;
proxy_redirect default;
rewrite ^/default/(.*) /$1 break;
client_max_body_size 500m;
}
location /map/ {
proxy_pass http://xxxx.xxxx.xxxx.xxx:2222/;
rewrite ^/map/(.*) /$1 break;
client_max_body_size 500m;
}
}
}
nginx反向代理配置(针对vue项目打包后跨域)
最新推荐文章于 2025-06-23 09:34:13 发布