zoukankan      html  css  js  c++  java
  • lemp-------3多站点访问,,访问控制,,虚拟目录

    基于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/;
    }

    重启

    测试

  • 相关阅读:
    SQL关闭连接,及分离数据库
    C# 用户选择单个压缩-系统自带压缩
    设计模式7大原则--01
    httpclient
    Mac idea 常用命令
    集合整理
    几种简单的排序算法
    基础数据结构简介
    git 常用命令3
    git 常用命令2
  • 原文地址:https://www.cnblogs.com/han1094/p/6379496.html
Copyright © 2011-2022 走看看