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

    重启

    测试

  • 相关阅读:
    java web 工程更改名字
    [转]Eclipse下开发Struts奇怪异常:org.apache.struts.taglib.bean.CookieTei
    【转】myeclipse 自定义视图Customize Perspective 没有反应
    latex建立参考文献的超链接
    latex 脚注编号也成为超链接
    自定义标签TLD文件中,rtexprvalue子标签的意思
    设计模式观察者
    设计模式模板方法
    设计模式策略
    设计模式享元
  • 原文地址:https://www.cnblogs.com/han1094/p/6379496.html
Copyright © 2011-2022 走看看