linux:nginx
Nginx
Nginx是一个网页服务器,它能反向代理HTTP, HTTPS, SMTP, POP3, IMAP的协议链接,以及一个负载均衡器和一个HTTP缓存。
Installation
安装使用源码编译方式,参考Nginx 配置之完整篇和PageSpeed,启用多种速度和安全特性。
configure配置如下:
./configure --add-module=../ngx_pagespeed \ --add-module=../ngx_brotli \ --add-module=../nginx-ct \ --with-pcre-jit \ --with-openssl=../openssl \ --with-http_v2_module \ --with-http_ssl_module \ --with-http_gzip_static_module \ --with-threads \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_xslt_module \ --sbin-path=/usr/sbin/nginx \ --prefix=/usr/local/nginx \ --conf-path=/etc/nginx/nginx.conf \ --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log \ --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid \ --http-client-body-temp-path=/var/lib/nginx/body \ --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ --http-proxy-temp-path=/var/lib/nginx/proxy \ --http-scgi-temp-path=/var/lib/nginx/scgi \ --http-uwsgi-temp-path=/var/lib/nginx/uwsgi
Configuration
HTTPS
- https://cipherli.st/ 自动生成合适的SSL配置
- https://imququ.com/post/sth-about-switch-to-https-2.html 关于启用 HTTPS 的一些经验分享
An example ssl configuration:
- ssl.conf
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_cache shared:SSL:50m; ssl_session_timeout 1d; # openssl dhparam -out dhparams.pem 2048 ssl_dhparam /etc/nginx/ssl/dhparams.pem; ssl_prefer_server_ciphers on; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
Snippets
Redirect naked domain to www
Remember to replace [name]
to your own domain
- redirect.conf
server { listen 80; server_name [domain]; rewrite ^(.*)$ $scheme://www.[domain]$1 permanent; }
linux/nginx.txt · 最后更改: 2023/12/03 10:24 由 127.0.0.1