实用的 Nginx 配置片段
一组实用的 Nginx 片段。
内容目录
- The Nginx Command
- Rewrite and Redirection </li>
- Performance
- Contents Caching
- Gzip Compression
- Open File Cache
- SSL Cache
- Upstream Keepalive </ul> </li>
- Monitoring
- Security
- Enable Basic Authentication
- Only Allow Access From Localhost </ul> </li>
- Miscellaneous
- Sub-Request Upon Completion
- Enable Cross Origin Resource Sharing </ul> </li>
- Links </ul>
- Get current Nginx version and its configured compiling parameters:nginx -V
- Test the current Nginx configuration file and / or check its location:nginx -t
- Reload the configuration without restarting Nginx:nginx -s reload
The Nginx Command
Thenginxcommand can be used to perform some useful actions when Nginx is running.
Rewrite and Redirection
Force www
The right way is to define a separated server for the naked domain and redirect it.
server { listen 80; server_name example.org; return 301 $scheme://www.example.org$request_uri; } server { listen 80; server_name www.example.org; ... }
https://github.com/lebinh/nginx-confNote that this also works with HTTPS site.
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!