Spaces:
Runtime error
Runtime error
Create nginx.conf
Browse files- nginx.conf +51 -0
nginx.conf
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
events {
|
| 2 |
+
worker_connections 1024;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
http {
|
| 6 |
+
include /etc/nginx/mime.types;
|
| 7 |
+
default_type application/octet-stream;
|
| 8 |
+
|
| 9 |
+
upstream streamlit {
|
| 10 |
+
server localhost:8501;
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
server {
|
| 14 |
+
listen 7860;
|
| 15 |
+
server_name localhost;
|
| 16 |
+
|
| 17 |
+
# Restricted CORS configuration for elevatics.cloud
|
| 18 |
+
add_header Access-Control-Allow-Origin "https://elevatics.cloud" always;
|
| 19 |
+
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
| 20 |
+
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always;
|
| 21 |
+
add_header X-Frame-Options "ALLOW-FROM https://elevatics.cloud" always;
|
| 22 |
+
add_header Content-Security-Policy "frame-ancestors https://elevatics.cloud" always;
|
| 23 |
+
|
| 24 |
+
# Handle OPTIONS method
|
| 25 |
+
if ($request_method = "OPTIONS") {
|
| 26 |
+
add_header Access-Control-Allow-Origin "https://elevatics.cloud" always;
|
| 27 |
+
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
|
| 28 |
+
add_header Access-Control-Allow-Headers "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization" always;
|
| 29 |
+
add_header Access-Control-Max-Age 1728000;
|
| 30 |
+
add_header Content-Type text/plain;
|
| 31 |
+
add_header Content-Length 0;
|
| 32 |
+
return 204;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
location / {
|
| 36 |
+
proxy_pass http://streamlit;
|
| 37 |
+
proxy_set_header Host $host;
|
| 38 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 39 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 40 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 41 |
+
proxy_redirect off;
|
| 42 |
+
proxy_http_version 1.1;
|
| 43 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 44 |
+
proxy_set_header Connection "upgrade";
|
| 45 |
+
|
| 46 |
+
# Additional security headers for iframe
|
| 47 |
+
add_header X-Frame-Options "ALLOW-FROM https://elevatics.cloud" always;
|
| 48 |
+
add_header Content-Security-Policy "frame-ancestors https://elevatics.cloud" always;
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}
|