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

    重启

    测试

  • 相关阅读:
    requets中urlencode的问题
    洛谷$P4503 [CTSC2014]$企鹅$QQ$ 哈希
    洛谷$P5446 [THUPC2018]$绿绿和串串 $manacher$
    洛谷$P5329 [SNOI2019]$字符串 字符串
    洛谷$P1390$ 公约数的和 欧拉函数
    洛谷$P4318$ 完全平方数 容斥+二分
    入门懵逼钨丝繁衍
    $ CometOJ-Contest#11 D$ $Kruscal$重构树
    洛谷$P4884$ 多少个1? 数论
    入门数论简单总结
  • 原文地址:https://www.cnblogs.com/han1094/p/6379496.html
Copyright © 2020-2023  润新知