博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
lemp-------3多站点访问,,访问控制,,虚拟目录
阅读量:4634 次
发布时间:2019-06-09

本文共 1822 字,大约阅读时间需要 6 分钟。

基于ip

vi /etc/nginx/nginx.conf

server {

listen 192.168.1.142:80;
server_name localhost;
access_log logs/host.access.log main;
location / {
root /web2;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 192.168.1.143:80;
server_name localhost;
location / {
root /web3;
index index.html index.htm index.php;
}
}

 

 

测试

 

*********************************************************************

基于端口

vi /etc/nginx/nginx.conf

server {

listen 192.168.1.142:80;
server_name localhost;
access_log logs/host.access.log main;
location / {
root /web2;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 192.168.1.142:81;
server_name localhost;
location / {
root /web3;
index index.html index.htm index.php;
}
}

 

 

****************************************************************************************

基于域名

vi /etc/nginx/nginx.conf

server {

listen 192.168.1.142:80;
server_name www.lei.com;
access_log logs/host.access.log main;
location / {
root /web2;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 192.168.1.142:80;
server_name www.han.com;
location / {
root /web3;
index index.html index.htm index.php;
}
}

 

 

 

*******************************************************************************************

访问控制

vi /etc/nginx/nginx.conf

在location / {中添加

auth_basic "mima";

auth_basic_user_file /usr/local/nginx/conf/.passwd.db;

 

生成密码

htpasswd -cm /usr/local/nginx/conf/.passwd.db aaa

 

 

*****************************************************************************************

虚拟目录

vi /etc/nginx/nginx.conf

在server中写

location /aaa {

alias /web3/;
}

 

重启

测试

 

转载于:https://www.cnblogs.com/han1094/p/6379496.html

你可能感兴趣的文章
centos7下安装docker
查看>>
推荐一个MacOS苹果电脑系统解压缩软件
查看>>
命令行编译运行CSharp文件
查看>>
HDOJ 1060 Leftmost Digit
查看>>
1035等差数列末项计算
查看>>
ASP.NET MVC 2示例Tailspin Travel
查看>>
nonatomic, retain,weak,strong用法详解
查看>>
第10周进度条
查看>>
编写函数求两个整数 a 和 b 之间的较大值。要求不能使用if, while, switch, for, ?: 以 及任何的比较语句。...
查看>>
CDMA鉴权
查看>>
ASP.NET MVC Identity 兩個多個連接字符串問題解決一例
查看>>
#include<bits/stdc++.h>包含C++的所有头文件
查看>>
Vue插槽 slot
查看>>
软考之路-网络攻击:主动攻击和被动攻击
查看>>
《windows核心编程系列》二谈谈ANSI和Unicode字符集
查看>>
知识图谱学习笔记(1)
查看>>
第三方原理
查看>>
同意好友
查看>>
随机映射
查看>>
servlet对mysql数据库的数据增删改
查看>>