Commit ba561e03 authored by salma's avatar salma

updaye nginx.conf

parent b3495679
FROM nginx:alpine FROM nginx:alpine
# 1. Remove default Nginx config
RUN rm /etc/nginx/conf.d/default.conf RUN rm /etc/nginx/conf.d/default.conf
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 2. Copy OUR optimized Global Nginx config
# (Make sure nginx.conf is in the same folder as this Dockerfile)
COPY nginx.conf /etc/nginx/nginx.conf
# 3. Copy your website files
COPY . /usr/share/nginx/html/ COPY . /usr/share/nginx/html/
EXPOSE 80 EXPOSE 80
......
server { worker_processes auto;
listen 80; worker_rlimit_nofile 65535; # Allow Nginx to open many files
# The root directory for your files inside the container events {
root /usr/share/nginx/html; worker_connections 10240; # Allow 10k connections per worker
index index.html; multi_accept on; # Accept all new connections at once
use epoll; # Efficient event processing on Linux
# This is important: it ensures that if you refresh a page on a }
# specific route, it doesn't give a 404 error. It will always
# serve the index.html file, allowing your frontend routing to work. http {
location / { include /etc/nginx/mime.types;
try_files $uri $uri/ /index.html; default_type application/octet-stream;
}
# LOGGING: Disable access logs during stress test to save Disk I/O
access_log off;
error_log /var/log/nginx/error.log crit;
# OPTIMIZATIONS
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100000;
reset_timedout_connection on;
# TIMEOUTS (Don't keep dead connections open)
client_body_timeout 10;
send_timeout 2;
# GZIP COMPRESSION (Reduces bandwidth usage)
gzip on;
gzip_min_length 10240;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
gzip_disable "MSIE [1-6]\.";
# OPEN FILE CACHE (Crucial for static sites)
# Caches file descriptors so Nginx doesn't read the disk for every request
open_file_cache max=200000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Cache images aggressively in the browser to save bandwidth
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
}
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment