docker/planet/default.conf
server {
listen 80;
sendfile on;
default_type application/octet-stream;
gzip on;
gzip_http_version 1.1;
gzip_disable "MSIE [1-6]\.";
gzip_min_length 1100;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_comp_level 9;
root /usr/share/nginx/html;
location /eng {
autoindex on;
try_files $uri$args $uri$args/ /eng/index.html =404;
}
location /ara {
autoindex on;
try_files $uri$args $uri$args/ /ara/index.html =404;
}
location /spa {
autoindex on;
try_files $uri$args $uri$args/ /spa/index.html =404;
}
location /nep {
autoindex on;
try_files $uri$args $uri$args/ /nep/index.html =404;
}
location /fra {
autoindex on;
try_files $uri$args $uri$args/ /fra/index.html =404;
}
location /som {
autoindex on;
try_files $uri$args $uri$args/ /som/index.html =404;
}
location / {
try_files $uri$args /eng/$uri$args /eng/index.html =404;
}
location = /latest {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "$document_root/latest.sh";
fastcgi_pass unix://run/fcgi.sock;
}
location = /time {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "$document_root/time.sh";
fastcgi_pass unix://run/fcgi.sock;
}
location = /upgrade {
include fastcgi_params;
if ($args ~ "v=(.{1,})$") {
set $version $1;
}
if ($args !~ "v=(.{1,})$") {
return 400;
}
fastcgi_read_timeout 900;
fastcgi_param SCRIPT_FILENAME "$document_root/upgrade.sh";
fastcgi_param PLANET_VERSION "$version";
fastcgi_pass unix://run/fcgi.sock;
}
location = /updateyml {
include fastcgi_params;
if ($args ~ "u=(.{1,})$") {
set $credentials $1;
}
if ($args !~ "u=(.{1,})$") {
return 400;
}
fastcgi_param SCRIPT_FILENAME "$document_root/credentials.sh";
fastcgi_param PLANET_CREDENTIALS "$credentials";
fastcgi_pass unix://run/fcgi.sock;
}
location = /updateconf {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "$document_root/credentials.sh";
fastcgi_param PLANET_CREDENTIALS "$credentials";
fastcgi_pass unix://run/fcgi.sock;
}
location = /version {
add_header 'Access-Control-Allow-Origin' '*';
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
add_header Content-Type text/plain;
}
location = /versions {
add_header 'Access-Control-Allow-Origin' '*';
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
add_header Content-Type text/plain;
}
location = /apkversion {
add_header 'Access-Control-Allow-Origin' '*';
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
add_header Content-Type text/plain;
try_files /fs/apkversion @empty;
}
location /_session {
proxy_pass http://couchdb:5984/_session;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 1024M;
}
location /ml/ {
proxy_pass http://chatapi:5000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 1024M;
}
location /db/ {
proxy_pass http://couchdb:5984/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 1024M;
}
location /pb/ {
set $test "";
if ($request_uri !~ /pb/(.*)/_find){
set $test "F";
}
if ($request_method !~ ^(GET|HEAD)$ ){
set $test "${test}G";
}
if ($test = "FG"){
return 500;
}
rewrite /pb/(.*) /$1 break; #this is for the new url of couchdb after it being proxy-passed
proxy_pass http://couchdb:5984;
proxy_buffering off; #don't buffer data before forward it to couchb
proxy_set_header Host $host; #don't change hosts from the original request
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #know the origin of the request
client_max_body_size 1024M;
include /etc/nginx/conf.d/auth.txt;
}
location = /upgrade/planetapk {
include fastcgi_params;
fastcgi_read_timeout 900;
fastcgi_param SCRIPT_FILENAME "$document_root/upgrade_planetapk.sh";
fastcgi_pass unix://run/fcgi.sock;
}
location = /upgrade/fromnation/planetapk {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "$document_root/upgrade_planetapk_fromnation.sh";
fastcgi_pass unix://run/fcgi.sock;
}
location = /healthaccess {
include fastcgi_params;
if ($args ~ "p=(.{1,})$") {
set $credentials $1;
}
if ($args !~ "p=(.{1,})$") {
return 400;
}
fastcgi_param SCRIPT_FILENAME "$document_root/set_health_security.sh";
fastcgi_param SATELLITE_CREDENTIALS "$credentials";
fastcgi_pass unix://run/fcgi.sock;
}
location = /storage {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME "$document_root/storage.sh";
fastcgi_pass unix://run/fcgi.sock;
}
location @empty {
return 200 '';
}
}