zoukankan      html  css  js  c++  java
  • Nginx如何进行虚拟主机配置

    虚拟主机技术能够让同一台服务器、同一组Nginx进程上运行多个网站,降低了资金和服务器资源的损耗。Nginx可以配置三种类型的虚拟主机,本文就是主要介绍这三种虚拟主机配置方式。

    配置基于IP的虚拟主机

    基于IP的虚拟主机就是直接把server_name设置为不同IP即可完成配置

    http
    {
      server 
      {
         listen 80;
         server_name 192.168.6.53;
         access_log logs/server1.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server1
         }
      }
      server 
      {
         listen 80;
         server_name 192.168.6.54;
         access_log logs/server2.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server2
         }
      }
      server 
      {
         listen 80;
         server_name 192.168.6.55;
         access_log logs/server3.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server3
         }
      }
    }
    

    基于域名的虚拟主机

    基于域名的虚拟主机就是直接把server_name设置为不同域名即可完成配置

    http
    {
      server 
      {
         listen 80;
         server_name a.domain.com;
         access_log logs/a.domain.com.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server1
         }
      }
      server 
      {
         listen 80;
         server_name b.domain.com;
         access_log logs/b.domain.com.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server2
         }
      }
      server 
      {
         listen 80;
         server_name www.domain domain.com *.domain.com;
         access_log logs/server3.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server3
         }
      }
    }
    

    基于端口的虚拟主机

    基于端口的虚拟主机就是直接把listen设置成不同的端口即可完成配置

    http
    {
      server 
      {
         listen 80;
         server_name 192.168.6.53
         access_log logs/server1.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server1
         }
      }
      server 
      {
         listen 8080;
         server_name 192.168.6.53
         access_log logs/server2.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server2
         }
      }
      server 
      {
         listen 10080;
         server_name 192.168.6.53
         access_log logs/server3.access.log commbined;
         
         location / 
         {
             index index.html;
             root/data1/wwwroot/server3
         }
      }
    }
    
  • 相关阅读:
    洛谷-P1855 榨取kkksc03
    Error: ORA-06502: PL/SQL: 数字或值错误 : character string buffer too small(触发器中使用系统动态视图导致)
    jwt ctf
    apktool+nuclei mobile
    Subdomain Takeover via Fastly ( Steps )
    乱七八糟
    Recon
    推荐几个我感觉不错的tips
    子域名收集
    清除Cookie的数据
  • 原文地址:https://www.cnblogs.com/phonecom/p/10437411.html
Copyright © 2011-2022 走看看