• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

nginx梳理

武飞扬头像
糖果店的幽灵
帮助1

Nginx总结

内容介绍

nginx

  • 1、 nginx 简介

    • 1 什么是 nginx 和可以做什么事情

    • 2 正向代理

    • 3 反向代理

    • 4 动静分离

  • 2、 Nginx 的安装

    • 1 在 linux 系统中安装 nginx
  • 3、 Nginx 的常用命令和配置文件

  • 4、 Nginx 配置实例 1 反向代理

  • 5、 Nginx 配置实例 2 负载均衡

  • 6、 Nginx 配置实例 3 动静分离

  • 7、 Nginx 的高可用集群

    1 nginx 配置主从模式

    2 nginx 配置双主模式

Nginx 的简介

1、什么是 nginx

Nginx 是高性能的 HTTP 和反向代理的服务器,处理高并发能力是十分强大的,能经受高负

载的考验,有报告表明能支持高达 50,000 个并发连接数。

2、正向代理

需要在客户端配置代理服务器进行指定网站访问

学新通

3、反向代理

暴露的是代理服务器地址,隐藏了真实服务器 IP 地址

学新通

4、负载均衡

增加服务器的数量,然后将请求分发到各个服务器上,将原先请求集中到单个服务器上的

情况改为将请求分发到多个服务器上,将负载分发到不同的服务器,也就是我们所说的负

载均衡。

学新通

5、动静分离

学新通

Nginx 的安装

1、准备工作

(1)打开虚拟机,使用远程连接工具连接** linux 操作系统

(2)到 nginx 官网下载软件

http://nginx.org/

2、开始进行** nginx 安装

1)安装pcre 依赖

第一步 联网下载 pcre 压缩文件依赖

wget http://downloads.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz

第二步 解压压缩文件

使用命令 tar –xvf pcre-8.37.tar.gz

第三步./configure 完成后,回到 pcre 目录下执行 make,最后执行 make install

2)安装 openssl **、**zlib gcc 依赖

yum -y install make zlib zlib-devel gcc-c libtool openssl openssl-devel

3)安装 nginx

***** 使用命令解压

*** ./configure**

*** make && make install**

进入目录 /usr/local/nginx/sbin/nginx 启动服务

Nginx 的常用的命令

# 进入到nginx目录中

cd /use/local/nginx/sbin
# 查看nginx版本号
./nginx -v
# 启动nginx
./nginx
# 停止nginx
./nginx -s stop
# 重新加载nginx
./nginx -s reload

Nginx 的配置文件

1、**nginx **配置文件位置

手动安装的nginx配置文件一般在 /usr/local/nginx/conf/nginx.conf

Yum 安装的nginx可能在 /etc/nginx

2、配置文件中的内容

包含三部分内容

1)全局块:配置服务器整体运行的配置指令

比如 **worker_processes 1;**处理并发数的配置

2events 块:影响 Nginx 服务器与用户的网络连接

比如 worker_connections 1024; 支持的最大连接数为 1024

3http

还包含两部分:

http 全局块

server

Nginx 配置实例-反向代理实例 1

 # nacos 端口8848  通过8847访问nginx反向代理到nacos
 				# 定义nacos的端口 可以定义多个
 				upstream nacoscluster {
        			server localhost:8848;
        }

        server {
        listen       8847;
        server_name  localhost;


						location /nacos/ {
            proxy_pass http://nacoscluster/nacos/;
        		}

        location = /50x.html {
            root   html;
        }
        error_page   500 502 503 504  /50x.html;
    }

Nginx 配置实例-负载均衡

 				upstream nacoscluster {
        			server localhost:8847;
        			server localhost:8848;
        }
        
        server {
        listen       80;
        server_name  localhost;
						location /nacos/ {
            proxy_pass http://nacoscluster/nacos/;
        }

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbgjif
系列文章
更多 icon
同类精品
更多 icon
继续加载