0、背景
领导要验证多域名使用80端口访问同一服务器上的多个站点。
1、方案
1) 在IIS 7中建立2个站点分别为 SiteA 端口1005, SiteB 端口1006。
2)配置域名有3种方式
2.1)本机测试
在host中配置域名指定到服务器
2.2)公司内访问
在DNS服务器配置域名指向到目标服务器
略...
2.3)新网二级域名解析
配置解析到目标公网ip端口然后做nat内部映射
略...
3) Nginx 方式
实验目录:E:\Work\nginx-1.13.9-2\nginx-1.13.9\conf
3.1)Nginx 80端口访问本地多站点
server {
listen 80;
server_name a.site.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root G:/SiteA;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name b.site.com;
location / {
root G:/SiteB;
index index.html index.htm;
}
}
3.2)反向代理80端口访问其他服务器多站点
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name a.site.com;
location / {
proxy_pass http://oa.ken_ji_jian.com:7001;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name b.site.com;
location / {
proxy_pass http://ams.jijian.com:7003;
}
}