go-fastdfs/docker-compose/nginx/nginx.conf
2021-08-31 16:17:45 +08:00

92 lines
4.4 KiB
Nginx Configuration File
Raw 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.

worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/html;
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;
error_log /var/log/nginx/error.log error;
sendfile on;
keepalive_timeout 65;
rewrite_log on;
client_max_body_size 0;
proxy_redirect ~/(\w+)/big/upload/(.*) /$1/big/upload/$2; #继点续传一定要设置(注意)
#以下是一下横向扩展的配置,当前统一大集群容量不够时,只要增加一个小集群,也就是增加一个
#upstream ,一个小群集内按业务需求设定副本数,也就是机器数。
upstream gofastdfs-group1 {
server 127.0.0.1:8080;
#server 10.1.14.37:8082;
ip_hash; #notice:very important(注意)
}
#upstream gofastdfs-group2 {
# server 10.1.51.70:8083;
#server 10.1.14.36:8083;
# ip_hash; #notice:very important(注意)
# }
server {
listen 80;
server_name localhost;
location ~ /godfs/group(\d) {
#统一在url前增加godfs,以便统一出入口。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/group(\d) /group$1 break;
proxy_pass http://gofastdfs-group$1;
}
location ~ /godfs/upload {
#这是一个横向扩展配置前期可能只有一个集群group1,当group1满后只需将上传指向group2,
#也就是将rewrite , proxy_pass 中的group1改为group2即可。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/upload /group1/upload break;
proxy_pass http://gofastdfs-group1;
}
location ~ /godfs/big/upload {
#以上上类似。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/upload /group1/big/upload break;
proxy_pass http://gofastdfs-group1;
}
location ~ /godfs/delete {
#以上上类似。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/delete /group1/delete break;
proxy_pass http://gofastdfs-group1;
}
location ~ /godfs/list {
#以上上类似。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/list /group1/list_dir break;
proxy_pass http://gofastdfs-group1;
}
location ~ /godfs/file {
#以上上类似。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/file /group1/get_file_info break;
proxy_pass http://gofastdfs-group1;
}
location ~ /godfs/reload {
#以上上类似。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
rewrite ^/godfs/reload /group1/reload break;
proxy_pass http://gofastdfs-group1;
}
}
}