现有3台服务器
192.168.1.225 nginx
192.168.1.229 其他应用服务
192.168.1.234 minio
nginx配置文件如下
1 # For more information on configuration, see: 2 # * Official English Documentation: http://nginx.org/en/docs/ 3 # * Official Russian Documentation: http://nginx.org/ru/docs/ 4 5 user nginx; 6 worker_processes auto; 7 error_log /var/log/nginx/error.log; 8 pid /run/nginx.pid; 9 10 # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. 11 #include /usr/share/nginx/modules/*.conf; 12 13 events { 14 worker_connections 1024; 15 } 16 17 http { 18 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 19 '$status $body_bytes_sent "$http_referer" ' 20 '"$http_user_agent" "$http_x_forwarded_for"'; 21 22 access_log /var/log/nginx/access.log main; 23 24 sendfile on; 25 tcp_nopush on; 26 tcp_nodelay on; 27 keepalive_timeout 65; 28 types_hash_max_size 2048; 29 client_max_body_size 10240m; 30 31 upstream portal { 32 server 192.168.1.229:8080 weight=1; 33 # server 127.0.0.1:8080 weight=1; 34 } 35 36 upstream minio { 37 server 192.168.1.234:9000 weight=1; 38 } 39 40 include /etc/nginx/mime.types; 41 default_type application/octet-stream; 42 43 # Load modular configuration files from the /etc/nginx/conf.d directory. 44 # See http://nginx.org/en/docs/ngx_core_module.html#include 45 # for more information. 46 #include /etc/nginx/conf.d/*.conf; 47 48 server { 49 listen 80 default_server; 50 #listen [::]:80 default_server; 51 server_name _; 52 root /usr/share/nginx/html; 53 54 # Load configuration files for the default server block. 55 #include /etc/nginx/default.d/*.conf; 56
#根路径转发到应用服务 57 location / { 58 proxy_pass http://portal; 59 proxy_set_header Host $host; 60 proxy_set_header X-Real-Ip $remote_addr; 61 proxy_set_header X-Forwarded-For $remote_addr; 62 63 }
#minio文件共享路径 64 location /oss/ { 65 proxy_pass http://minio/; 66 proxy_set_header Host $http_host; 67 proxy_set_header X-Real-Ip $remote_addr; 68 proxy_set_header X-Forwarded-For $remote_addr; 69 proxy_set_header X-Forwarded-Proto $scheme; 70 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 71 72 } 73
#访问minio网页路径 74 location /minio/ { 75 proxy_pass http://192.168.1.234:9000; 76 proxy_set_header Host $host; 77 proxy_set_header X-Real-Ip $remote_addr; 78 proxy_set_header X-Forwarded-For $remote_addr; 79 80 } 81 82 error_page 404 /404.html; 83 location = /40x.html { 84 } 85 86 error_page 500 502 503 504 /50x.html; 87 location = /50x.html { 88 } 89 } 90 91 # Settings for a TLS enabled server. 92 # 93 # server { 94 # listen 443 ssl http2 default_server; 95 # listen [::]:443 ssl http2 default_server; 96 # server_name _; 97 # root /usr/share/nginx/html; 98 # 99 # ssl_certificate "/etc/pki/nginx/server.crt"; 100 # ssl_certificate_key "/etc/pki/nginx/private/server.key"; 101 # ssl_session_cache shared:SSL:1m; 102 # ssl_session_timeout 10m; 103 # ssl_ciphers HIGH:!aNULL:!MD5; 104 # ssl_prefer_server_ciphers on; 105 # 106 # # Load configuration files for the default server block. 107 # include /etc/nginx/default.d/*.conf; 108 # 109 # location / { 110 # } 111 # 112 # error_page 404 /404.html; 113 # location = /40x.html { 114 # } 115 # 116 # error_page 500 502 503 504 /50x.html; 117 # location = /50x.html { 118 # } 119 # } 120 121 }