5-Ngnix配置基于用户访问控制和IP的虚拟主机
目录
5.1.Ngnix配置基于用户访问控制的多虚拟主机
5.1.1.前提条件
5.1.2.Ngnix配置基于用户访问控制的多虚拟主机
5.2.Ngnix配置基于IP的虚拟主机
5.3.Ngnix配置基于IP的多虚拟主机
Nginx配置文件在/usr/local/nginx/conf下,文件名为nginx.conf
5.1.Ngnix配置基于用户访问控制的多虚拟主机
5.1.1.前提条件
Ngnix配置基于用户访问控制的多虚拟主机时,需要使用htpasswd命令,需要安装httpd-tools rpm
命令:
yum install -y httpd-tools
[root@cent79-2 ~]# yum install -y httpd-tools
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* centos-sclo-rh: mirrors.huaweicloud.com* centos-sclo-sclo: mirrors.huaweicloud.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 will be installed
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-tools-2.4.6-99.el7.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-tools-2.4.6-99.el7.centos.1.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7_9.1 will be installed
--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================Package Arch Version Repository Size
=============================================================================================================
Installing:httpd-tools x86_64 2.4.6-99.el7.centos.1 updates 94 k
Installing for dependencies:apr x86_64 1.4.8-7.el7 CentOS7 104 kapr-util x86_64 1.5.2-6.el7_9.1 updates 92 kTransaction Summary
=============================================================================================================
Install 1 Package (+2 Dependent packages)Total download size: 290 k
Installed size: 584 k
Downloading packages:
(1/2): apr-util-1.5.2-6.el7_9.1.x86_64.rpm | 92 kB 00:00:00
(2/2): httpd-tools-2.4.6-99.el7.centos.1.x86_64.rpm | 94 kB 00:00:00
-------------------------------------------------------------------------------------------------------------
Total 356 kB/s | 290 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionInstalling : apr-1.4.8-7.el7.x86_64 1/3 Installing : apr-util-1.5.2-6.el7_9.1.x86_64 2/3 Installing : httpd-tools-2.4.6-99.el7.centos.1.x86_64 3/3 Verifying : apr-util-1.5.2-6.el7_9.1.x86_64 1/3 Verifying : apr-1.4.8-7.el7.x86_64 2/3 Verifying : httpd-tools-2.4.6-99.el7.centos.1.x86_64 3/3 Installed:httpd-tools.x86_64 0:2.4.6-99.el7.centos.1 Dependency Installed:apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.el7_9.1 Complete!
[root@cent79-2 ~]#
5.1.2.Ngnix配置基于用户访问控制的多虚拟主机
-->进入/usr/local/nginx/conf目录
命令:
cd /usr/local/nginx/conf
pwd
[root@cent79-2 conf]# cd /usr/local/nginx/conf/
[root@cent79-2 conf]# pwd
/usr/local/nginx/conf
[root@cent79-2 conf]#
-->编辑nginx.conf,并保存
命令:
vi nginx.conf
--> 验证nginx.conf语法的正确性
命令:
nginx -t
[root@cent79-2 conf]# nginx -t
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful
[root@cent79-2 conf]#
-->创建用户访问控制文件
命令:
htpasswd -c /usr/local/nginx/conf/nginxpasswd ztj
[root@cent79-2 conf]# htpasswd -c /usr/local/nginx/conf/nginxpasswd ztj
New password:
Re-type new password:
Adding password for user ztj
[root@cent79-2 conf]# cat /usr/local/nginx/conf/nginxpasswd
ztj:$apr1$bKLsHgJ3$X8j4Buj2KCw4ojcm3HuTX1
[root@cent79-2 conf]#
备注:
如果创建多个用户访问控制时,后续命令为:
htpasswd /usr/local/nginx/conf/nginxpasswd USERNAME
-->重启nginx
命令:
nginx -s stop
nginx
[root@cent79-2 conf]# nginx -s stop
[root@cent79-2 conf]# ps -ef |grep nginx
root 1354 1245 0 15:39 pts/0 00:00:00 grep --color=auto nginx
[root@cent79-2 conf]# nginx
[root@cent79-2 conf]# ps -ef |grep nginx
root 1356 1 0 15:39 ? 00:00:00 nginx: master process nginx
nginx 1357 1356 0 15:39 ? 00:00:00 nginx: worker process
root 1359 1245 0 15:40 pts/0 00:00:00 grep --color=auto nginx
[root@cent79-2 conf]#
-->验证
http://www.itztj.com
输入通过htpasswd命令创建的用户控制文件的用户名和密码
http://www.itxiaohei.com
输入通过htpasswd命令创建的用户控制文件的用户名和密码
5.2.Ngnix配置基于IP的虚拟主机
-->进入/usr/local/nginx/conf目录
命令:
cd /usr/local/nginx/conf
pwd
[root@cent79-2 conf]# cd /usr/local/nginx/conf/
[root@cent79-2 conf]# pwd
/usr/local/nginx/conf
[root@cent79-2 conf]#
-->编辑nginx.conf,并保存
命令:
vi nginx.conf
--> 验证nginx.conf语法的正确性
命令:
nginx -t
[root@cent79-2 conf]# nginx -t
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful
[root@cent79-2 conf]#
-->重新加载nginx
命令:
nginx -s reload
[root@cent79-2 conf]# nginx -s reload
[root@cent79-2 conf]# ps -ef |grep nginx
root 1591 1 0 16:04 ? 00:00:00 nginx: master process nginx
nginx 1594 1591 0 16:04 ? 00:00:00 nginx: worker process
root 1596 1182 0 16:05 pts/0 00:00:00 grep --color=auto nginx
[root@cent79-2 conf]#
-->验证
curl 192.168.10.156
[root@cent79-2 conf]# curl 192.168.10.156
I am itztj
[root@cent79-2 conf]#
宿主机验证
5.3.Ngnix配置基于IP的多虚拟主机
-->进入/usr/local/nginx/conf目录
命令:
cd /usr/local/nginx/conf
pwd
[root@cent79-2 conf]# cd /usr/local/nginx/conf/
[root@cent79-2 conf]# pwd
/usr/local/nginx/conf
[root@cent79-2 conf]#
-->编辑nginx.conf,并保存
命令:
vi nginx.conf
--> 验证nginx.conf语法的正确性
命令:
nginx -t
[root@cent79-2 conf]# nginx -t
nginx: the configuration file /usr/local/nginx//conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx//conf/nginx.conf test is successful
[root@cent79-2 conf]#
-->重新加载nginx
命令:
nginx -s reload
[root@cent79-2 conf]# nginx -s reload
[root@cent79-2 conf]# ps -ef |grep nginx
root 1591 1 0 16:04 ? 00:00:00 nginx: master process nginx
nginx 1594 1591 0 16:04 ? 00:00:00 nginx: worker process
root 1596 1182 0 16:05 pts/0 00:00:00 grep --color=auto nginx
[root@cent79-2 conf]#
-->验证
相关文章:

5-Ngnix配置基于用户访问控制和IP的虚拟主机
目录 5.1.Ngnix配置基于用户访问控制的多虚拟主机 5.1.1.前提条件 5.1.2.Ngnix配置基于用户访问控制的多虚拟主机 5.2.Ngnix配置基于IP的虚拟主机 5.3.Ngnix配置基于IP的多虚拟主机 Nginx配置文件在/usr/local/nginx/conf下,文件名为nginx.conf 5.1.Ngnix配置…...
springboot jar分离部署
springboot jar分离部署 注意:spring boot web项目别使用jsp页面,可以使用模板代替,jsp打包时访问页面会报404错误。 1.具体配置如下: <build><plugins><!--更换maven的jar打包插件先前使用的是spring-boot-mav…...

Opencv 细节补充
1.分辨率的解释 •像素:像素是分辨率的单位。像素是构成位图图像最基本的单元,每个像素都有自己的颜色。 •分辨率(解析度): a) 图像分辨率就是单位英寸内的像素点数。单位为PPI(Pixels Per Inch) b) PPI表示的是每英…...
内存泄漏专题(7)hook之宏定义
前面介绍的mtrace也好,bcc也罢,其实都是hook技术的一种实现,但是mtrace本身使用场景上有局限,而bcc环境依赖则十分复杂。因此,这些调试手段只适用于开发环境用来调试,对于生产环境,均不是一个非…...

Python 基础(十八):异常处理
❤️ 博客主页:水滴技术 🌸 订阅专栏:Python 入门核心技术 🚀 支持水滴:点赞👍 收藏⭐ 留言💬 文章目录 一、异常是什么?二、异常处理的基本语法三、捕获特定的异常类型四、finall…...

iTOP-RK3568开发板Docker 安装 Ubuntu 18.04
Docker 下载安装 Ubuntu18.04,输入以下命令: sudo apt update docker pull ubuntu:18.04 切换 Shell 到 Ubuntu 18.04,输入以下命令: docker container run -p 8000:3000 -it ubuntu:18.04 /bin/bash -p 参数:容器的…...

FFmpeg AVFilter的原理(三)- filter是如何被驱动的
首先上官方filter的链接:https://ffmpeg.org/ffmpeg-filters.html 关于filter命令行:FFmpeg-4.0 的filter机制的架构与实现.之一 Filter原理 1、下面是一个avfilter的graph 上图是ffmpeg中doc/examples中filtering_video.c案例的示意图。 特别注意上面蓝…...

ARM day8 key1/2/3led
key_led.h #ifndef _KEY_H_ #define _KEY_H_#include "stm32mp1xx_rcc.h" #include "stm32mp1xx_gpio.h" #include "stm32mp1xx_exti.h" #include "stm32mp1xx_gic.h"//EXTI编号 typedef enum {EXTI0,EXTI1,EXTI2,EXTI3,EXTI4,EXTI5,…...

windows 系统安装sonarqube
SonarQube是一种自动代码审查工具,用于检测代码中的错误,漏洞和代码异味。它可以与您现有的工作流程集成,以便在项目分支和拉取请求之间进行连续的代码检查。 官方网站: https://www.sonarqube.org/ 1. 使用前提条件 运行SonarQ…...

Unity噪声图生成(编辑器扩展)
最近发现项目里很多shader都需要噪声图,(shadergraph中有自己的噪声图生成)当遇到需要噪声图时去寻找很麻烦,所以从网上查阅资料编写了一个Unity扩展的噪声图生成。 Perlin噪声 Perlin噪声是一种渐变噪声算法,由Ken …...
http-为什么文件上传要转成Base64
# 前言 最近在开发中遇到文件上传采用Base64的方式上传,记得以前刚开始学http上传文件的时候,都是通过content-type为multipart/form-data方式直接上传二进制文件,我们知道都通过网络传输最终只能传输二进制流,所以毫无疑问他们本…...

htmlCSS-----定位
目录 前言 定位 分类和取值 定位的取值 1.相对定位 2.绝对位置 元素居中操作 3.固定定位 前言 今天我们来学习html&CSS中的元素的定位,通过元素的定位我们可以去更好的将盒子放到我们想要的位置,下面就一起来看看吧! 定位 定位posi…...
腾讯云大数据型CVM服务器实例D3和D2处理器CPU型号说明
腾讯云服务器CVM大数据型D3和D2处理器型号,大数据型D3云服务器CPU采用2.5GHz Intel Xeon Cascade Lake 处理器,大数据型D2云服务器CPU采用2.4GHz Intel Xeon Skylake 6148 处理器。腾讯云服务器网分享云服务器CVM大数据型CPU型号、处理器主频性能&#x…...

计算机科学cs/电子信息ei面试准备——数学基础/线性代数复习
1. 中值定理 中值定理是反映函数与导数之间联系的重要定理,也是微积分学的理论基础,在许多方面它都有重要的作用,在进行一些公式推导与定理证明中都有很多应用。中值定理是由众多定理共同构建的,其中拉格朗日中值定理是核心&…...
极速查找(2)-算法分析
篇前小言 本篇文章是对查找(1)的续讲线性索引查找 线性索引查找(Linear Index Search)是一种基于索引的查找算法。它在数据集合中创建一个索引 结构,然后使用该索引结构来加快对目标元素的查找。 线性索引是一种在数…...

flask路由添加参数
flask路由添加参数 在 Flask 中,可以通过两种方式在路由中添加参数:在路由字符串中直接指定参数,或者通过 request 对象从请求中获取参数。 在路由字符串中指定参数:可以将参数直接包含在路由字符串中。参数可以是字符串、整数、…...

网络安全系统教程+学习路线(自学笔记)
一、什么是网络安全 网络安全可以基于攻击和防御视角来分类,我们经常听到的 “红队”、“渗透测试” 等就是研究攻击技术,而“蓝队”、“安全运营”、“安全运维”则研究防御技术。 无论网络、Web、移动、桌面、云等哪个领域,都有攻与防两面…...
23. 合并 K 个升序链表
题目描述 给你一个链表数组,每个链表都已经按升序排列。 请你将所有链表合并到一个升序链表中,返回合并后的链表。 示例 1: 输入:lists [[1,4,5],[1,3,4],[2,6]] 输出:[1,1,2,3,4,4,5,6] 解释:链表数组…...

Nexus3部署、配置+SpringBoot项目Demo
Docker部署Nexus 搜索Nexus3镜像:[rootlocalhost ~]# docker search nexus 拉取Nexus3镜像:[rootlocalhost ~]# docker pull sonatype/nexus3 启动Nexus3前查看虚拟机端口是否被占用:[rootlocalhost ~]# netstat -nultp 通过Docker Hub查看安…...

linux下用docker安装mysql
1.mysql Docker镜像 docker pull mysql:[版本号 或 latest]例:docker pull mysql:5.7 2.查看拉取的docker镜像 docker images3.设置 Docker 卷 docker volume create mysql-data列出 Docker 已知的所有卷 docker volume ls4.运行一个 MySQL Docker 容器 docke…...
挑战杯推荐项目
“人工智能”创意赛 - 智能艺术创作助手:借助大模型技术,开发能根据用户输入的主题、风格等要求,生成绘画、音乐、文学作品等多种形式艺术创作灵感或初稿的应用,帮助艺术家和创意爱好者激发创意、提高创作效率。 - 个性化梦境…...
设计模式和设计原则回顾
设计模式和设计原则回顾 23种设计模式是设计原则的完美体现,设计原则设计原则是设计模式的理论基石, 设计模式 在经典的设计模式分类中(如《设计模式:可复用面向对象软件的基础》一书中),总共有23种设计模式,分为三大类: 一、创建型模式(5种) 1. 单例模式(Sing…...

VB.net复制Ntag213卡写入UID
本示例使用的发卡器:https://item.taobao.com/item.htm?ftt&id615391857885 一、读取旧Ntag卡的UID和数据 Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click轻松读卡技术支持:网站:Dim i, j As IntegerDim cardidhex, …...
mongodb源码分析session执行handleRequest命令find过程
mongo/transport/service_state_machine.cpp已经分析startSession创建ASIOSession过程,并且验证connection是否超过限制ASIOSession和connection是循环接受客户端命令,把数据流转换成Message,状态转变流程是:State::Created 》 St…...
Qt Widget类解析与代码注释
#include "widget.h" #include "ui_widget.h"Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget) {ui->setupUi(this); }Widget::~Widget() {delete ui; }//解释这串代码,写上注释 当然可以!这段代码是 Qt …...
渲染学进阶内容——模型
最近在写模组的时候发现渲染器里面离不开模型的定义,在渲染的第二篇文章中简单的讲解了一下关于模型部分的内容,其实不管是方块还是方块实体,都离不开模型的内容 🧱 一、CubeListBuilder 功能解析 CubeListBuilder 是 Minecraft Java 版模型系统的核心构建器,用于动态创…...
linux 下常用变更-8
1、删除普通用户 查询用户初始UID和GIDls -l /home/ ###家目录中查看UID cat /etc/group ###此文件查看GID删除用户1.编辑文件 /etc/passwd 找到对应的行,YW343:x:0:0::/home/YW343:/bin/bash 2.将标红的位置修改为用户对应初始UID和GID: YW3…...

Reasoning over Uncertain Text by Generative Large Language Models
https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829https://ojs.aaai.org/index.php/AAAI/article/view/34674/36829 1. 概述 文本中的不确定性在许多语境中传达,从日常对话到特定领域的文档(例如医学文档)(Heritage 2013;Landmark、Gulbrandsen 和 Svenevei…...

回溯算法学习
一、电话号码的字母组合 import java.util.ArrayList; import java.util.List;import javax.management.loading.PrivateClassLoader;public class letterCombinations {private static final String[] KEYPAD {"", //0"", //1"abc", //2"…...
SQL慢可能是触发了ring buffer
简介 最近在进行 postgresql 性能排查的时候,发现 PG 在某一个时间并行执行的 SQL 变得特别慢。最后通过监控监观察到并行发起得时间 buffers_alloc 就急速上升,且低水位伴随在整个慢 SQL,一直是 buferIO 的等待事件,此时也没有其他会话的争抢。SQL 虽然不是高效 SQL ,但…...