cqdevicemgt/config/nginx.conf.0722

108 lines
2.0 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server_tokens off;
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;
client_max_body_size 100M;
client_body_buffer_size 100M;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
#gzip on;
upstream auth {
server 192.168.0.56:39200;
}
upstream gateway {
server 192.168.0.56:39080;
}
upstream base {
server 192.168.0.56:39301;
}
upstream material {
server 192.168.0.56:39302;
}
upstream system {
server 192.168.0.56:39201;
}
server {
listen 80;
server_name localhost;
charset utf-8;
location / {
# 网站根目录,此处使用容器内的路径
root /usr/share/nginx/html/;
# 默认首页
index index.html;
# 尝试从磁盘找到请求的文件,如果不存在则跳转到 index.html
try_files $uri $uri/ /index.html;
}
location /auth/ {
proxy_pass http://auth/;
}
location /code/ {
proxy_pass http://gateway;
}
location /base/ {
proxy_pass http://base/;
}
location /material/ {
proxy_pass http://material/;
}
location /system/ {
proxy_pass http://system/;
}
location /dev-api/ {
rewrite ^/dev-api/(.*)$ /$1 break; #必须的写这个使用nginx的rewrite对uri进行重写 下面这行也要改为api
proxy_pass http://192.168.0.56:39080/; #跨域转发路由地址
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}