¸®´ª½º °ü·Ã °Á¶õ |
---|
Á¦¸ñ | apache virtual host #1 1998/12/12 (10:46) |
À̸§ | ±èÈ¿¿ø |
¹øÈ£ | 70 |
Á¶È¸ | 480 |
º»¹® |
Apach Server¿¡¼ Name server ¼ÂÆðú Virtual server ¼ÂÆà Çϱâ <Â÷·Ê> 1. Sub domain µî·ÏÇϱâ 2. ÇϳªÀÇ ip·Î Sub domain Ãß°¡Çϱâ 3. »õ·Î¿î Domain Ãß°¡Çϱâ RED HAT¿¡¼ virtual host¼³Á¤Àº named¿Í Webserver¿Í IP alias¸¦ º¯°æÇØ ÁÜÀ¸·Î¼ ÀÌ·ç¾î Áø´Ù. IP alias´Â ÇÑ°³ÀÇ nic¿¡ ¿©·¯°³ÀÇ °¡»ó µð¹ÙÀ̽º¸¦ Àâ´Â °ÍÀ» ¸»ÇÑ´Ù. ±×·¯¹Ç·Î ÇÑ´ëÀÇ ¼¹ö¿¡ ¿©·¯°³ÀÇ È£½ºÆ® À̸§À¸·Î À¥¼¹ö¸¦ ±¸ÃàÇÒ¼ö ÀÖÀ¸¸ç CNAMEÀ» ÀÌ¿ë Çϸé ÇϳªÀÇ IP·Î¼ ¿©·¯°³ÀÇ ¼ºêµµ¸ÞÀÎÀ» ÁöÁ¤ÇÒ ¼ö ÀÖ´Ù. ÀÏ´Ü Ä¿³Î ÄÄÆÄÀϽà Networking options¿¡¼ ip aliasing¿Í network alisingÀ» üũ ÇÏ¿©¾ß ÇÑ´Ù. ³×ÀÓ ¼¹ö ±¸ÃàÀº ¹ØÀÇ ³ª¿ì´©¸® ¸®´ª½º µ¿È£È¸ÀÇ name server°Á¸¦ ÂüÁ¶Ç϶ó. 1. Sub domainµî·ÏÇϱâ ÀÚ½ÅÀÇ named°¡ ¾îµðÀÖ´ÂÁö ¸ð¸¥´Ù¸é whereis named¸¦ ÇÏ¸é ³ª¿Ã°ÍÀÌ´Ù ±×·¯¸é ±×°÷À¸·Î À̵¿À» ÇÑ´Ù. # ns:/var/named# vi oops.zone # ; made by oops@oops.ml.org # ; # @ IN SOA ns.oops.ml.org. root.ns.oops.ml.org. ( # 980226 ;serial ==> ³¯Â¥ ²À º¯°æÇØ Áà¾ß ÇÔ!!! # 10800 ;Refresh # 3600 ;Retry # 432000 ;Expire # 84600) ;Minimum (12h) # # IN NS ns.oops.ml.org. # IN NS ns2.oops.ml.org. # IN MX 0 ns.oops.ml.org. # ; # IN A 210.126.21.90 # ns IN A 210.126.21.90 # IN HINFO Pentium-200MHz dual Linux # # ns2 IN A 147.46.104.4 # # www IN CNAME ns.oops.ml.org. # # poolkim IN A 210.126.21.91 # ktk IN A 210.126.21.92 # test IN A 210.126.21.93 -> ÀÌ¿Í °°ÀÌ Ãß°¡ # # hda IN CNAME street.oops.ml.org. # # "oops.zone" 32 lines, 857 characters written .zone file¿¡¼´Â ÀÌ¿ëÇÒ sub domainÀ» Á¤ÀǸ¦ ÇØÁÖ´Â °÷ÀÌ´Ù ÀÚ½ÅÀÌ »ç¿ëÇÒ ¼ºê domainÀ» ÁöÁ¤ÇÏ°í ±× ¿·¿¡ ÇÒ´çÇÒ IP¸¦ Àû´Â´Ù. # ns:/var/named# vi oops.rev # @ IN SOA ns.oops.ml.org. root.ns.oops.ml.org. ( # # 980204 ;serial => À̺κР¿ª½Ã º¯°æ! # ====== # 10800 ;Refresh # 3600 ;Retry # 432000 ;Expire # 84600) ;Minimum (12h) # # IN NS ns.oops.ml.org. # IN NS ns.nuri.net. # ; # 90 IN PTR ns.oops.ml.org. # 91 IN PTR poolkim.oops.ml.org. # 92 IN PTR ktk.oops.ml.org. # 93 IN PTR test.oops.ml.org. -> ÀÌ¿Í °°Àº Çü½ÄÀ¸·Î Ãß°¡ # ~ # ~ # "oops.rev" [readonly] 21 lines, 901 characters .rev fileÀº ÇØ´ç domain¿¡ ip¸¦ ÁöÁ¤ÇØ ÁØ´Ù. ÀÌ IP´Â ÇÒ´ç ¹ÞÀº IPÀÇ Á¦ÀÏ ³¡ÀÚ¸® ¼ö·Î ÁöÁ¤ÇÑ´Ù. ÀÌ fileÀº ptrÅ×À̺íÀ» ±¸¼ºÇÏ´Â fileÀÔ´Ï´Ù. ptrÅ×À̺íÀÌ ¹«¾ùÀÎÁö¿¡ ´ëÇÑ °ÍÀº ³×ÀÓ¼¹ö °Á¸¦ Âü°íÇϼ¼¿ä. # ns:/var/named# ps -ax | grep named -> namedÀÇ PID¸¦ ã´Â´Ù # 258 ? S 1:54 /usr/sbin/named # ns:/var/named# kill -HUP 258 -> named¸¦ refreshÇÑ´Ù ps¸í·É¾î·Î namedÀÇ PID¸¦ È®ÀÎÇÑÈÄ named¸¦ ¸®Ç÷¹½¬¸¦ ÇÑ´ÙÀ½ ¹Ø°ú °°ÀÌ È®ÀÎÀ» ÇØ º»´Ù # ns:/var/named# nslookup # Default Server: ns.oops.ml.org # Address: 210.126.21.90 # # > test -> Ãß°¡ÇÑ ¼ºê µµ¸ÞÀÎ # Server: ns.oops.ml.org # Address: 210.126.21.90 # # Name: test.oops.ml.org # Address: 210.126.21.93 # # > exit ´ÙÀ½Àº À¥¼¹öÀÇ httpd.conf fileÀÇ virtualhostºÎºÐÀ» ÆíÁýÇÒ Â÷·ÊÀÌ´Ù ÀÚ½ÅÀÇ À¥¼¹ö°¡ ¼³Ä¡µÇ¾î Àִ°÷À¸·Î À̵¿À» ÇÑ´Ù. ¾îµð¿¡ ÀÖ´ÂÁö ¸ð¸¥´Ù¸é whereis httd¸¦ ÇϸéµÈ´Ù. # ns:/var/named# cd /usr/local/etc/httpd/ # # ns:/usr/local/etc/httpd# ls # cgi-bin conf httpd icons logs proxy # # ns:/usr/local/etc/httpd# cd conf # # ns:/usr/local/etc/httpd/conf# ls # access.conf httpd.conf mime.types srm.conf # # ns:/usr/local/etc/httpd/conf# vi httpd.conf <----------file ³»¿ë-----------> # This is the main server configuration file. See URL http://www.apache.org/ # Do NOT simply read the instructions in here without understanding # what they do, if you are unsure consult the online docs. You have been # Port: The port the standalone listens to. For ports < 1023, you will # HostnameLookups: Log the names of clients or just their IP numbers # e.g. www.apache.org (on) or 204.62.129.132 (off) # You should probably turn this off unless you are going to actually # use the information in your logs, or with a CGI. Leaving this on # can slow down access to your site. # If you wish httpd to run as a different user or group, you must run # If you wish httpd to run as a different user or group, you must run # User/Group: The name (or #number) of the user/group to run httpd as. # On SCO (ODT 3) use User nouser and Group nogroup # On HPUX you may not be able to use shared memory as nobody, and the # suggested workaround is to create a user www and use that user. User nobody # The following directive disables keepalives and HTTP header flushes for # Netscape 2.x and browsers which spoof it. There are known problems with # ServerAdmin: Your address, where problems with the server should be # ServerRoot: The directory the server's config, error, and log files # BindAddress: You can support virtual hosts with this option. This option # is used to tell the server which IP address to listen to. It can either # is used to tell the server which IP address to listen to. It can either # contain "*", an IP address, or a fully qualified Internet domain name. # ErrorLog: The location of the error log file. If this does not start # TransferLog: The location of the transfer log file. If this does not # PidFile: The file the server should log its pid to # ScoreBoardFile: File used to store internal server process information. # Not all architectures require this. But if yours does (you'll know because # this file is created when you run Apache) then you *must* ensure that # no two invocations of Apache share the same scoreboard file. # ServerName allows you to set a host name which is sent back to clients for # your server if it's different than the one the program would get (i.e. use # "www" instead of the host's real name). # "www" instead of the host's real name). # # Note: You cannot just invent host names and hope they work. The name you # define here must be a valid DNS name for your host. If you don't understand # CacheNegotiatedDocs: By default, Apache sends Pragma: no-cache with each # document that was negotiated on the basis of content. This asks proxy # servers not to cache the document. Uncommenting the following line disables # KeepAlive: Whether or not to allow persistent connections (more than # MaxKeepAliveRequests: The maximum number of requests to allow # during a persistent connection. Set to 0 to allow an unlimited amount. # Server-pool size regulation. Rather than making you guess how many # server processes you need, Apache dynamically adapts to the load it # sees --- that is, it tries to maintain enough server processes to # handle the current load, plus a few spare servers to handle transient # load spikes (e.g., multiple simultaneous requests from a single # It does this by periodically checking how many servers are waiting # for a request. If there are fewer than MinSpareServers, it creates # a new spare. If there are more than MaxSpareServers, some of the MinSpareServers 5 # Limit on total number of servers running, i.e., limit on the number # of clients who can simultaneously connect --- if this limit is ever # of clients who can simultaneously connect --- if this limit is ever # reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW. # It is intended mainly as a brake to keep a runaway server from taking # MaxRequestsPerChild: the number of requests each child process is # allowed to process before the child dies. # The child will exit so as to avoid problems after prolonged use when # Apache (and maybe the libraries it uses) leak. On most systems, this # isn't really needed, but a few (such as Solaris) do have notable leaks # Proxy Server directives. Uncomment the following line to # CacheRoot /usr/local/etc/httpd/proxy # CacheSize 100000 # CacheGcInterval 4 # CacheMaxExpire 24 # CacheLastModifiedFactor 0.1 # CacheLastModifiedFactor 0.1 # CacheDefaultExpire 12 #NoCache a_domain.com another_domain.edu joes.garage_sale.com # Listen: Allows you to bind Apache to specific IP addresses and/or #Listen 3000 # VirtualHost: Allows the daemon to respond to requests for more than one # server address, if your server machine is configured to accept IP packets # for multiple addresses. This can be accomplished with the ifconfig # Any httpd.conf or srm.conf directive may go into a VirtualHost command. #<VirtualHost host.some_domain.com> #ServerAdmin webmaster@host.some_domain.com #DocumentRoot /www/docs/host.some_domain.com #ServerName host.some_domain.com #ErrorLog logs/host.some_domain.com-error_log #TransferLog logs/host.some_domain.com-access_log <VirtualHost test.oops.ml.org> -> Ãß°¡ÇÒ µµ¸ÞÀÎÀ» °°ÀÌ Àû´Â´Ù ServerAdmin oops@oops.ml.org -> masterÀÇ e-mail»ç¿ë DocumentRoot /home/test/htdocs -> home µð·ºÅ丮 ¼³Á¤ ServerName test.oops.ml.org -> Ãß°¡ÇÒ µµ¸ÞÀÎ¸í ¼³Á¤ ErrorLog logs/test.error_log -> error log »ý¼º µð·ºÅ丮 ¼³Á¤ TransferLog logs/test.access_log -> access log »ý¼º µð·ºÅ丮 ¼³Á¤ </VirtualHost> ~ ~ # "httpd.conf" 237 lines, 7914 characters written # <------------file end----------------> fileÀÇ Á¦ÀÏ ¸¶Áö¸· ºÎºÐ¿¡ <VirtualHost>¿Í </VirtualHost>¿¡ ¼³Á¤À» ÇØ ÁÖ¸é µÈ´Ù. ´ÙÀ½ IP aliasingÀ» ÇØ Áà¾ß ÇÑ´Ù. ÀÏ´Ü °¡»ó IP¸¦ NIC¿¡ ÇÒ´çÀ» ÇÑ´Ù. # /sbin/iconfig eth0:x( x= 1 - 256 ) 210.126.21.y( y=ÇÒ´çÇÒ IP ) ¿©±â¼ eth0Àº NICÀÇ µð¹ÙÀ̽º ³×ÀÓÀÌ¸ç µÚ¿¡ ':¼ýÀÚ'¸¦ ºÙÀÓÀ¸·Î¼ °¡»ó µð¹ÙÀ̽º¸¦ »ý¼ºÇÑ´Ù ±×´ÙÀ½ ÀÌ °¡»ó µð¹ÙÀ̽º¸¦ ¶ó¿ìÆ® ¼ÂÆÿ¡ Ãß°¡ÇÑ´Ù # /sbin/route add -host 210.126.21.x dev(»ý·«°¡´É) eth0:x À§¿Í °°ÀÌ ¼³Á¤ÇÑ ÈÄ ´ÙÀ½°ú °°ÀÌ ifconfig¸¦ »ç¿ëÇÏ¿© µð¹ÙÀÌ ½º°¡ È°¼ºÈ µÈ°ÍÀ» È®ÀÎÇÒ¼ö ÀÖ´Ù. lo Link encap:Local Loopback inet addr:127.0.0.0 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1 RX packets:5088 errors:0 dropped:0 overruns:0 TX packets:5088 errors:0 dropped:0 overruns:0 eth0 Link encap:10Mbps Ethernet HWaddr 00:8E:B8:83:19:20 inet addr:210.126.21.90 Bcast:203.236.108.255 Mask:255.255.255.0 UP BROADCAST RUNNING PROMISC MULTICAST MTU:1500 Metric:1 RX packets:334036 errors:0 dropped:0 overruns:0 TX packets:11605 errors:0 dropped:0 overruns:0 Interrupt:7 Base address:0x378 eth0:0 Link encap:10Mbps Ethernet HWaddr 00:8E:B8:83:19:20 inet addr:210.126.21.91 Bcast:203.236.108.255 Mask:255.255.255.0 UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 TX packets:0 errors:0 dropped:0 overruns:0 eth0:1 Link encap:10Mbps Ethernet HWaddr 00:8E:B8:83:19:20 inet addr:210.126.21.92 Bcast:203.236.108.255 Mask:255.255.255.0 UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:1 errors:0 dropped:0 overruns:0 TX packets:0 errors:0 dropped:0 overruns:0 eth0:2 Link encap:10Mbps Ethernet HWaddr 00:8E:B8:83:19:20 inet addr:210.126.21.93 Bcast:203.236.108.255 Mask:255.255.255.0 UP BROADCAST RUNNING MTU:1500 Metric:1 RX packets:1 errors:0 dropped:0 overruns:0 TX packets:0 errors:0 dropped:0 overruns:0 routing tableÀ» È®ÀÎ ÇÏ·Á¸é netstat -nrÀ» »ç¿ëÇÏ¿© È®ÀÎÇÑ´Ù. °á°ú´Â ´ÙÀ½°ú °°´Ù... Kernel IP routing table Destination Gateway Genmask Flags MSS Windows irtt Iface 210.126.21.91 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0:0 210.126.21.92 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0:1 210.126.21.93 0.0.0.0 255.255.255.255 UH 1500 0 0 eth0:2 210.126.21.90 0.0.0.0 255.255.255.128 U 1500 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 3584 0 0 lo 0.0.0.0 210.126.21.254 0.0.0.0 UG 1500 0 0 eth0 ´ÙÀ½ rc.alias¶ó´Â fileÀ» ¸¸µç´ÙÀ½¿¡ ÀÌ ³»¿ëÀ» ±âÀÔÀ» ÇØ ÁÖ¸é µÈ´Ù. # ns:/usr/local/etc/httpd/conf# cd /etc/rc.d # ns:/etc/rc.d# ls # rc.0 rc.K rc.alias rc.inet2 rc.serial # rc.4 rc.M rc.cdrom rc.local # rc.6 rc.S rc.inet1 rc.modules # ns:/etc/rc.d# vi rc.alias # /sbin/ifconfig lo 127.0.0.1 # /sbin/ifconfig eth0 up # /sbin/ifconfig eth0 210.126.21.90 # /sbin/ifconfig eth0:0 210.126.21.91 # /sbin/ifconfig eth0:1 210.126.21.92 # /sbin/ifconfig eth0:2 210.126.21.93 # # # /sbin/route add -net 127.0.0.0 # /sbin/route add -net 210.126.21.0 dev eth0 # /sbin/route add -host 210.126.21.90 eth0 # /sbin/route add -host 210.126.21.91 eth0:0 # /sbin/route add -host 210.126.21.92 eth0:1 # /sbin/route add -host 210.126.21.93 eth0:2 # ~ # ~ # "rc.alias" 25 lines, 790 characters written rc.alias¸¦ ¸¸µç ´ÙÀ½ /etc/rc.d/rc.loaclÀÇ Á¦ÀÏ ¾Æ·§ÁÙ¿¡ rc.alias¸¦ ±âÀÔÀ» ÇØÁØ´ÙÀ½ ÀúÀåÀ» ÇÏ°í ³ª¿Í¼ /etc/rc.d/rc.local ¸í·ÉÀ» ½ÇÇàÇÑ´ÙÀ½ route¸í·ÉÀ¸·Î ¼³Á¤ÇÑ°ÍÀÌ ÀâÇû´ÂÁö È®ÀÎÇØ º»´Ù. ´ÙÀ½ httpd¸¦ refleshÇÑ´Ù # ns:/etc/rc.d# more /usr/local/etc/httpd/logs/httpd.pid # 67 (À§ÀÇ °æ·Î¿Í ´Ù¸£´Ù¸é root¿¡¼ find / -name httpd.pid¸¦ ½ÇÇà¾Ö ºÁ¶ó!) ¶Ç´Â # ns:/etc/rc.d# ps -ax | grep inetd -> httpdÀÇ PID ã±â # 67 # ns:/etc/rc.d# kill -HUP 67 -> httpd reflesh ¸í·É <Âü°í1> stand alone¹æ½ÄÀ¸·Î apache µ¥¸óÀ» ½ÇÇàÇß´Ù¸é À§ÀÇ ¹æ½Ä´ë·Î ÇÏ°í inetd¸¦ ÀÌ¿ëÇÑ´Ù¸é ¹ØÀÇ ¹æ½Ä´ë·Î ÇÏ¸é µÈ´Ù. Âü°í·Î httpd.pid¿Í inetdÀÇ pid´Â ¼·Î ´Ù¸£´Ù. <Âü°í2> name¼¹ö¿¡ µî·ÏÀÌ µÇ¾ú´Ù°í Çؼ ¿ÜºÎ¿¡¼ ¹Ù·Î µî·ÏµÈ domainÀÌ ÀÎ½Ä µÇÁö´Â ¾Ê´Â´Ù. »óÀ§ name server¿¡¼ ÀνÄÀ» ÇØ Áà¾ß Çϱ⠶§¹®¿¡ zoneÀÇ ³¯Â¥¸¦ °íÃÄ Áà¾ß ÇÏ´Â °ÍÀÌ´Ù. ÀÏ´Ü À§ÀÇ °úÁ¤À» ´Ù °ÅÃÆÀ¸¸é ª°Ô´Â ÇÏ·ç ±æ°Ô´Â ÇÑ ÀÌ»ïÀÏ Á¤µµ ÈÄ¿¡´Â ¿ÜºÎ¿¡¼µµ µµ¸ÞÀÎÀÌ ÀÎ½Ä µÇ¾î Áø´Ù. ±èÁ¤±Õ. oops@netusers.net |