# 7.12 एका server वर अनेक websites

Source: https://ravindrabagale.com/mr/aws/ch07-static-website-hosting-3-oses-2-web-servers/7-12-hosting-multiple-sites-on-one-server-virtual.html
Language: mr (Marathi with English technical terms)

एका building मध्ये अनेक दुकानं: पत्ता एक, नावं वेगळी. HTTP Host header मधल्या domain वरून Nginx server_name किंवा Apache ServerName block निवडतो.

 site1.example.com ─┐                       ┌─► /var/www/site1
                    ├─► 13.233.10.25:80 ────┤
 site2.example.com ─┘   (one IP, one port)  └─► /var/www/site2

# Nginx: one server block per site
server { listen 80; server_name site1.example.com; root /var/www/site1; }
server { listen 80; server_name site2.example.com; root /var/www/site2; }

# Apache: one VirtualHost per site
<VirtualHost *:80>
    ServerName site1.example.com
    DocumentRoot /var/www/site1
</VirtualHost>
<VirtualHost *:80>
    ServerName site2.example.com
    DocumentRoot /var/www/site2
</VirtualHost>

दोन्ही domains चे DNS A records server च्या EIP कडे ठेवा — allocation 5.5/14.1 आणि domain steps Chapter 9. Domain नसताना laptop hosts file मध्ये sample 13.233.10.25 site1.example.com लिहून test करता येतं: Linux/Mac /etc/hosts, Windows C:\Windows\System32\drivers\etc\hosts. किंवा curl -H "Host: site1.example.com" http://13.233.10.25. स्वतःचा IP वापरा.

Lab

/var/www/site1 आणि site2 करा, वेगळे index pages आणि blocks. curl -H "Host: site1.example.com" http://localhost आणि site2 साठी तसंच run करून दोन वेगळे pages तपासा.

रवींद्र बागले यांची tip

Portfolio दाखवताना स्थिर domain आणि HTTPS उपयोगी. पण domain खरेदी करण्याआधी local Host-header tests पूर्ण करा; DNS endpoint बदलणार नाही याची व्यवस्था करा.
