Nginx:修订间差异

无编辑摘要
无编辑摘要
第58行: 第58行:
|}
|}


== Nginx配置 ==
=== 概览 ===


Nginx配置文件是特定格式的文本文件。默认情况下配置文件为<code>nginx.conf</code>,放在<code>/etc/nginx/</code>目录(某些操作系统也可能在<code>/usr/local/nginx/conf</code>或<code>/usr/local/etc/nginx</code>目录)。
<syntaxhighlight lang='JSON'>
user  nginx;
worker_processes  auto;
error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include      /etc/nginx/mime.types;
    default_type  application/octet-stream;
    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;
    keepalive_timeout  65;
    #gzip  on;
    include /etc/nginx/conf.d/*.conf;
}
</syntaxhighlight>
{{了解更多
|[https://docs.nginx.com/nginx/admin-guide/basic-functionality/managing-configuration-files/ Nginx 文档:Creating NGINX Plus and NGINX Configuration Files]
}}
=== 全局配置 ===
{{了解更多
|[https://nginx.org/en/docs/ngx_core_module.html Nginx 文档:核心模块]
}}
==  Web服务器 ==
{{了解更多
|[https://docs.nginx.com/nginx/admin-guide/web-server/web-server/  Nginx 文档:将 Nginx 和 Nginx Plus 配置为 Web 服务器‎]
}}
=== 配置 HTTPS 服务器 ===
== 负载平衡器 ==
== 邮件代理 ==


==资源==
==资源==
第64行: 第120行:
* Nginx 官网:https://nginx.org/
* Nginx 官网:https://nginx.org/
* Nginx Plus 官网:https://www.nginx.com/
* Nginx Plus 官网:https://www.nginx.com/
* Nginx 文档:https://docs.nginx.com/
* Nginx 文档:https://nginx.org/en/docs/
* Nginx Plus 文档:https://nginx.org/en/docs/
* Nginx Plus 文档:https://docs.nginx.com/
* Nginx 源代码:https://hg.nginx.org/nginx
* Nginx 源代码:https://hg.nginx.org/nginx
* Nginx 源代码镜像:https://github.com/nginx/nginx
* Nginx 源代码镜像:https://github.com/nginx/nginx

2021年9月17日 (五) 07:12的版本

Nginx(发音同“engine X”)是一款开源的Web服务器程序,也可以用作反向代理、负载平衡器、邮件代理和HTTP缓存。

简介

时间轴

  • 2002年,伊戈尔·赛索耶夫(俄语:Игорь Сысоев)开始开发Nginx,最初是为了解决C10k问题和俄罗斯Rambler搜索引擎及其门户网站使用。
  • 2004年10月4日,首次发布初始版本 Nginx 0.1.0 。
  • 2011年,成立一家同名公司,来提供支持和Nginx Plus付费版本。
  • 2019年3月11日,F5 Networks以6.7亿美元收购Nginx公司。
  • 2021年04月20日,发布nginx 1.20.0 版本。

了解更多 >> Nginx 官网 Nginx:Changes 维基百科:Nginx 维基百科:Nginx(英)


Nginx与Nginx Plus

Nginx Plus是Nginx的付费版本,Nginx Plus在开源Nginx基础上增加了一些功能和服务,如:

  • 高级负载平衡
  • 主动健康检查
  • 会话保持
  • 专业的技术支持

了解更多 >> Nginx Plus官网


安装

Docker安装

使用默认配置启动一个容器,接下来在浏览器访问本机ip可以看到Nginx页面。

docker run --name mynginx1 -p 80:80 -d nginx

将nginx容器内的日志目录、配置目录和网站目录分别映射到主机当前目录nginx文件夹下的log、conf和html

docker run -d -p 80:80 --name nginx -v $(pwd)/nginx/log/:/var/log/nginx -v $(pwd)/nginx/conf:/etc/nginx -v $(pwd)/nginx/html/:/usr/share/nginx/html  nginx

了解更多 >> Docker Hub:Nginx Nginx 文档:使用Docker部署Nginx或Nginx plus Nginx 博客:使用Docker部署Nginx或Nginx plus


Linux

快速入门

Nginx默认目录

目录 位置 描述

Nginx配置

概览

Nginx配置文件是特定格式的文本文件。默认情况下配置文件为nginx.conf,放在/etc/nginx/目录(某些操作系统也可能在/usr/local/nginx/conf/usr/local/etc/nginx目录)。

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    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;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

了解更多 >> Nginx 文档:Creating NGINX Plus and NGINX Configuration Files


全局配置

了解更多 >> Nginx 文档:核心模块


Web服务器

了解更多 >> Nginx 文档:将 Nginx 和 Nginx Plus 配置为 Web 服务器‎


配置 HTTPS 服务器

负载平衡器

邮件代理

资源

官网

书籍

相关网站