gealogiuya
This commit is contained in:
7
deployments/compose/nginx/Dockerfile
Normal file
7
deployments/compose/nginx/Dockerfile
Normal file
@@ -0,0 +1,7 @@
|
||||
FROM nginx:1.21-alpine
|
||||
|
||||
# Remove the default NGINX configuration file
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy your custom NGINX configuration file
|
||||
COPY ./deployments/compose/nginx/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
101
deployments/compose/nginx/nginx.conf
Normal file
101
deployments/compose/nginx/nginx.conf
Normal file
@@ -0,0 +1,101 @@
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name yourdomain.uz;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://localhost:PROJECT_PORT;
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header X-Real-IP $remote_addr;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# proxy_set_header X-Forwarded-Proto $scheme;
|
||||
# }
|
||||
#
|
||||
# location /static/ {
|
||||
# alias /path/project/assets/staticfiles/;
|
||||
# }
|
||||
#
|
||||
# location /media/ {
|
||||
# alias /path/project/assets/media/;
|
||||
# }
|
||||
#
|
||||
# location /assets/ {
|
||||
# alias /path/project/assets/;
|
||||
#
|
||||
# location ~ /.well-known/acme-challenge {
|
||||
# allow all;
|
||||
# root /var/www/html;
|
||||
# }
|
||||
# }
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name yourdomain.uz;
|
||||
return 301 https://$host$request_uri; # Redirect HTTP to HTTPS
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
server_name yourdomain.uz;
|
||||
|
||||
ssl_certificate /etc/letsencrypt/live/yourdomain.uz/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/yourdomain.uz/privkey.pem;
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
|
||||
|
||||
# Security headers
|
||||
add_header X-Frame-Options SAMEORIGIN;
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header Referrer-Policy no-referrer-when-downgrade;
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'";
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
# Maximize performance
|
||||
client_max_body_size 50M;
|
||||
keepalive_timeout 65;
|
||||
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:PROJECT_PORT; # your Django app's IP and port
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# WebSockets support
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "Upgrade";
|
||||
}
|
||||
|
||||
location /static/ {
|
||||
alias /path/project/assets/staticfiles/; # adjust the path to your static files
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
location /media/ {
|
||||
alias /path/project/assets/media/; # adjust the path to your media files
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
alias /path/project/assets/; # adjust the path to your assets
|
||||
expires 1y;
|
||||
access_log off;
|
||||
add_header Cache-Control "public";
|
||||
}
|
||||
|
||||
# Enable compression
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
gzip_proxied any;
|
||||
gzip_vary on;
|
||||
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user