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

    重启

    测试

  • 相关阅读:
    SSRS Fields cannot be used in page headers or footers
    mac os x 触摸板点击无效
    Android内核sysfs中switch类使用实例
    hdu1827之强联通
    解决Gradle执行命令时报Could not determine the dependencies of task ':compileReleaseJava'.
    我对Lamport Logical Clock的理解
    側滑删除进阶(七、八)
    管理之路(成长之路--五)
    Qt跨平台的一个例程
    IOS 开发推荐经常使用lib
  • 原文地址:https://www.cnblogs.com/han1094/p/6379496.html
Copyright © 2011-2022 走看看