48 lines
1.9 KiB
Nginx Configuration File
48 lines
1.9 KiB
Nginx Configuration File
user nginx;
|
||
worker_processes 1;
|
||
error_log /var/log/nginx/error.log warn;
|
||
pid /var/run/nginx.pid;
|
||
events {
|
||
worker_connections 1024;
|
||
}
|
||
http {
|
||
include /etc/nginx/mime.types;
|
||
client_max_body_size 0;
|
||
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 /var/log/nginx/access.log main;
|
||
sendfile on;
|
||
keepalive_timeout 65;
|
||
|
||
server {
|
||
listen 80;
|
||
server_name 192.168.10.207; ## 重要!!!修改成你的外网 IP/域名
|
||
|
||
location / { ## 前端项目
|
||
root /app;
|
||
index index.html index.htm;
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
location /admin-api/ { ## 后端项目 - 管理后台
|
||
proxy_pass http://specialty:48080/admin-api/; ## 重要!!!proxy_pass 需要设置为后端项目所在服务器的 IP
|
||
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;
|
||
}
|
||
|
||
location /app-api/ { ## 后端项目 - 用户 App
|
||
add_header Access-Control-Allow-Origin *;
|
||
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
|
||
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
|
||
proxy_pass http://specialty:48080/app-api/; ## 重要!!!proxy_pass 需要设置为后端项目所在服务器的 IP
|
||
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;
|
||
}
|
||
}
|
||
} |