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 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 user www-data; worker_processes auto; error_log logs/error.log; pid /run/ nginx.pid; worker_rlimit_nofile 8192 ; events { use epoll worker_connections 4096 ; } 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; client_header_buffer_size 128 k; large_client_header_buffers 4 128 k; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ; ssl_prefer_server_ciphers on; access_log /var/ log/nginx/ access.log; error_log /var/ log/nginx/ error.log; gzip on; gzip_disable "msie6" ; text/xml application/ xml application/xml+rss text/ javascript; include /etc/ nginx/conf.d/ *.conf; include /etc/ nginx/sites-enabled/ *; } mail { server { listen localhost:110 ; protocol pop3; proxy on; } server { listen localhost:143 ; protocol imap; proxy on; } }
总结来说
1 2 3 4 5 6 main:用于进行nginx全局信息的配置 events:用于nginx工作模式的配置 http :用于进行http 协议信息的一些配置server:用于进行服务器访问信息的配置 location:用于进行访问路由的配置 upstream:用于进行负载均衡的配置
目前使用的一些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 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 worker_processes 2 ;error_log /var/log/nginx/error .log;pid /run/nginx.pid;events { worker_connections 1024 ; } http { 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; 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; server { listen 80 ; server_name XXX.XXXX.com; return 301 https://$server_name $request_uri ; } server { listen 443 ; server_name XXX.XXXX.com; ssl on ; ssl_certificate cert/XXX.XXXX.pem; ssl_certificate_key cert/XXX.XXXX.key; ssl_session_timeout 5m ; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2 ; ssl_prefer_server_ciphers on ; location /{ proxy_pass http://localhost:8080; proxy_set_header X-Real-IP $remote_addr ; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; proxy_set_header Host $http_host ; proxy_set_header X-NginX-Proxy true ; } } }
原文链接: http://yoursite.com/2019/02/12/nginx-http和https配置/
版权声明: 转载请注明出处.