Skip to content

Commit

Permalink
feat(gateway): add oss conf in gateway;
Browse files Browse the repository at this point in the history
  • Loading branch information
maslow committed Apr 14, 2022
1 parent e533b93 commit c9b089f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 61 deletions.
62 changes: 1 addition & 61 deletions packages/gateway/conf.docker/fs-proxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -74,64 +74,4 @@ server {
ngx.log(ngx.ERR, '<$proxy_uri> ', ngx.var.proxy_uri, ' <$fixed_uri> ', ngx.var.fixed_uri);
}
}
}

# for user custom domain (TODO)
# server {
# listen 80 default_server;
# server_name _;

# gzip on;
# gzip_min_length 1k;
# gzip_buffers 4 16k;
# gzip_http_version 1.0;
# gzip_comp_level 2;
# gzip_types text/plain application/x-javascript text/css application/xml;

# location / {
# lua_code_cache off;
# set $userdomain default;
# access_by_lua_block {
# local host = ngx.var.host;
# local domain_cache = ngx.shared.domain_cache;
# # domain_cache:set(host, 'storage-service:9010/abed2f85-00ac-49c0-978d-c83aa3c1d8e8_public')
# local value = domain_cache:get(host);
# if value then
# ngx.var.userdomain = value;
# return
# end

# if not value then
# ngx.say('failed to proxy this domain');
# return
# end

# }

# resolver 127.0.0.11;

# #proxy
# proxy_ignore_headers Set-Cookie Cache-Control;
# proxy_hide_header Cache-Control;
# proxy_hide_header Set-Cookie;
# proxy_cache file_cache;
# proxy_cache_valid 200 304 60m;
# proxy_cache_valid any 5m;
# proxy_cache_revalidate on;
# proxy_cache_min_uses 3;
# proxy_cache_methods GET;
# proxy_cache_key key=$host$uri;
# add_header Nginx-Cache "$upstream_cache_status";
# add_header X-Accept "$http_accept";
# add_header cache-key "key=$host$uri";
# proxy_pass http://$userdomain?path=$request_uri&$query_string;
# proxy_set_header Host $userdomain;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

# # Logging
# log_by_lua_block {
# ngx.log(ngx.ERR, '<proxy domain>', ngx.var.userdomain)
# }
# }
# }
}
37 changes: 37 additions & 0 deletions packages/gateway/conf.docker/oss.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
lua_shared_dict domain_cache 128m;
proxy_cache_path /tmp/cache levels=1:2 keys_zone=file_cache:10m max_size=10g inactive=60m;

server {
listen 80;
server_name ${DEPLOY_OSS_DOMAIN};
client_max_body_size 0;

gzip on;
gzip_min_length 10k;
gzip_comp_level 1;
gzip_vary on;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/json font/ttf font/otf image/svg+xml;

location / {
# Allow CORS
add_header Access-Control-Allow-Origin * always;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,PATCH,OPTIONS always;
add_header Access-Control-Allow-Headers * always;
add_header Access-Control-Expose-Headers * always;
add_header Access-Control-Max-Age 3600 always;

if ($request_method = 'OPTIONS') {
return 204;
}

# resolve oss service
resolver 127.0.0.11;

# proxy
proxy_pass http://oss:9000/;
proxy_read_timeout 600s;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

0 comments on commit c9b089f

Please sign in to comment.