server-configs-nginx README

The project's README from github.com/h5bp/server-configs-nginx. As one markdown file: README.md.

Nginx Server Configs

Server CI

Nginx Server Configs is a collection of configuration files that can help your server improve the website's performance and security, while also ensuring that resources are served with the correct content-type and are accessible, if needed, even cross-domain.

Getting Started

Using the Nginx server configs repo directly has a few required steps to be able to work.

Check nginx.conf settings

The first thing to check is that the nginx.conf file contains appropriate values for your specific install.

Most specific variables are:

Nginx test and restart

Repository structure

This repository has the following structure:

./
├── conf.d/
│   ├── default.conf
│   └── templates/
├── h5bp/
│   ├── basic.conf
│   ├── location/
│   └── .../
├── custom.d/
│   └── .../
├── mime.types
└── nginx.conf

Usage

As a reference

To use as reference requires no special installation steps, download/checkout the repository to a convenient location and adapt your existing Nginx configuration incorporating the desired functionality from this repository.

Download the latest release archive.

Directly

To use directly, replace the Nginx config directory with this repository. For example:

nginx -s stop
cd /etc
mv nginx nginx-previous
git clone https://github.com/h5bp/server-configs-nginx.git nginx
# install-specific edits
nginx

Manage sites

cd /etc/nginx/conf.d
nginx -s reload

Support

Contributing

Anyone is welcome to contribute, however, if you decide to get involved, please take a moment to review the guidelines:

Acknowledgements

Nginx Server Configs is only possible thanks to all the awesome contributors!

License

The code is available under the MIT license.

server-configs-nginx (h5bp/server-configs-nginx)

Searching Database…

这是什么?这是一组现成的 Nginx 服务器配置文件(由 H5BP 项目提供),可以提升网站的性能和安全性,设置正确的内容类型,并处理跨域资源访问。
这是完整的 nginx.conf 替换方案,还是只需引入的片段?两者皆是:它附带一套完整的仓库结构(nginx.conf、mime.types、conf.d、templates),可直接使用;同时也提供单独的 h5bp/ 配置片段(mixins),可按需引入,例如 basic.conf 就打包了推荐的常驻规则。
我该如何开始使用这些配置?两种方式任选:下载或检出该仓库,把所需规则复制到你现有的 nginx.conf 中;或者直接用本仓库整体替换你的 Nginx 配置目录。
我需要哪个版本的 Nginx?Nginx 1.8.0 或更高版本。
在服务器上生效之前,我需要修改这些文件吗?需要。你必须检查 nginx.conf 中与安装环境相关的配置值(user、errorlog、pid、accesslog);如果使用提供的模板,还需将其复制到 conf.d 中,并把所有 example.com 替换为你的实际域名。
仓库是如何组织的,我该如何找到需要的内容?conf.d/ 存放服务器定义,templates/ 提供适用于安全和非安全主机的可直接复制的模板,h5bp/ 包含可复用的配置片段和 location/ 指令,custom.d/ 用于存放你自己的自定义配置,另外顶层还有 mime.types 和 nginx.conf 文件。
在应用配置之前,我如何检查配置是否有效?README 中记录了验证 Nginx 配置的命令、使用自定义文件路径进行验证的命令,以及无需重启即可重新加载 Nginx 以应用新配置的命令。
basic.conf 开箱即用能提供哪些功能?它会加载仓库规则中一小部分推荐的子集,用于添加 expires 响应头、允许跨域字体访问,并禁止网页访问系统文件。
我如何添加或删除网站?README 中列出了创建新网站的步骤,然后通过管理 sites 目录结构中对应的配置文件来启用或禁用该网站。
Creator
h5bp
Size
0.4 MB
Stars
11.6K
Age
13y
Commits · 90 Days