1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /run/nginx.pid;
events { worker_connections 1024; use epoll; multi_accept on; }
http {
client_body_temp_path /var/cache/nginx/client_temp; proxy_temp_path /var/cache/nginx/proxy_temp; fastcgi_temp_path /var/cache/nginx/fastcgi_temp;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
include /etc/nginx/mime.types; default_type application/octet-stream;
proxy_connect_timeout 6s; proxy_send_timeout 10s; proxy_read_timeout 10s; proxy_buffer_size 16k; proxy_buffers 4 32k; proxy_busy_buffers_size 64k; proxy_temp_file_write_size 64k;
gzip on; gzip_min_length 1k; gzip_types text/plain text/css application/json application/javascript application/xml;
server { listen 80;
server_name example.com;
if ($scheme != "https") { return 301 https://$server_name$request_uri; }
ssl_certificate /etc/nginx/ssl/server.crt; ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5;
location / { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; }
location /static/ { alias /path/to/static/files/; expires 7d; add_header Pragma public; add_header Cache-Control "public, must-revalidate, proxy-revalidate"; }
error_page 404 /404.html; location = /404.html { internal; root /usr/share/nginx/html; }
location /old/ { rewrite ^/old/([^/]+) /new/$1 permanent; } }
upstream backends { server backend1.example.com:8080 weight=5; server backend2.example.com:8080; server backend3.example.com:8080 backup; keepalive 16; }
server { listen 80; server_name example.com;
location / { proxy_pass http://backends; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } }
|