From 0178cc9cb52db370a6ea83ce27de849cf0b76429 Mon Sep 17 00:00:00 2001 From: leonard Date: Mon, 8 Apr 2024 14:38:15 +0200 Subject: [PATCH] fix nginx header to enable CORS + adding auto-restart in case on failure, such as Out Of Memory --- conf/nginx.conf | 16 ++++++++-------- conf/systemd.service | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 57e2c51..ef57e3a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -22,17 +22,17 @@ location __PATH__/ { return 204; } if ($request_method = 'POST') { - more_set_headers "Access-Control-Allow-Origin: * always"; - more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS always"; - more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range always"; - more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range always"; + more_set_headers "Access-Control-Allow-Origin: *"; + more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS"; + more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"; + more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range"; } if ($request_method = 'GET') { - more_set_headers "Access-Control-Allow-Origin: * always"; - more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS always"; - more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range always"; - more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range always"; + more_set_headers "Access-Control-Allow-Origin: *"; + more_set_headers "Access-Control-Allow-Methods: GET, POST, OPTIONS"; + more_set_headers "Access-Control-Allow-Headers: DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range"; + more_set_headers "Access-Control-Expose-Headers: Content-Length,Content-Range"; } # this is needed if you have file import via upload enabled diff --git a/conf/systemd.service b/conf/systemd.service index 84dd1bb..525c3b1 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -12,6 +12,11 @@ Environment="UVICORN_ROOT_PATH=__PATH__" ExecStart=__INSTALL_DIR__/venv/bin/gunicorn --config __INSTALL_DIR__/gunicorn.conf.py FastAPIAppFolder:app --worker-class uvicorn.workers.UvicornWorker +Restart=on-failure +RestartSec=1s +StartLimitIntervalSec=60 +StartLimitBurst=5 + StandardOutput=syslog StandardError=syslog SyslogIdentifier=__APP__-server