原文链接:Nginx代理多个域名服务配置参考[Django][Nginx][Uwsgi][资源服务器]
nginx.conf 基础配置
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
| user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;
events { worker_connections 768; } http {
sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048;
include /etc/nginx/mime.types; default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf; }
|
nginx配置网站
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
| upstream django { server 127.0.0.1:8001; }
server { listen 80; server_name www.aidroid.top aidroid.top ; charset utf-8; client_max_body_size 75M;
location /media { alias /web/djangoweb/media; } location /static { alias /web/djangoweb/static; }
location / { uwsgi_pass django; include /etc/nginx/uwsgi_params; } }
|
nginx实现静态资源服务器配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| autoindex on; autoindex_exact_size off; autoindex_localtime on; charset utf-8;
server { listen 80; server_name resource.aidroid.top; root /web/resource; error_log /web/logs/res_error.log ;
location / { }
error_page 404 /404.html; location = /40x.html { }
error_page 500 502 503 504 /50x.html; location = /50x.html { } }
|
nginx 配置端口服务,同时启动blog/main/email/resource多个代理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| server { listen 80; server_name blog.aidroid.top ; charset utf-8; client_max_body_size 75M;
location / { proxy_pass http://127.0.0.1:8002; proxy_set_header Host $proxy_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
}
|