相信有些服务器还是无可奈何的使用windows作为服务器,比如需要运行asp
可是要灵活rewrite和防盗链之类的,IIS可就麻烦了,一个不愿多碰的玩意
既然需要用,那就可以使用一个灵活的web服务在前面,后面放IIS,让它好好的退居二线。
一线位置的可选软件有:Nginx和apache
两者都可以提供足够的灵活性,如果还需要运行php,那不妨安装一些套件,比如:
我习惯用后者,用起来也还挺方便。
相对而言,apache的一些代理功能并非很灵活,用起来就有点复杂了。比如用正则匹配的方式条件性的进行代理,这个需要2.2.5版本以上才支持。nginx还是很不错的一个选择,代理功能非常强大,配置简洁,前端服务器的不二选择,各个大型网站都开始启用nginx,使用量风风火火的往上爬。
使用方法:
我们把IIS的默认网站停了,新建一个虚拟主机,端口号是88或者其它非80的未使用的端口即可,我们用这个作为处理asp的后端,别的不用它处理了。
当然了,下面是安装apache或者nginx。
apache和nginx作为前端,负责处理静态文件,并且把asp文件的请求交给后端。
apache的配置参考:
(httpd-vhosts.conf)
Nginx的配置参考:
(判断代码,非全部)
后端的asp获得用户ip的方式:
nginx的windows版本还算稳定,不过,不适用 -s reload 的方式重新加载配置文件,也不适合开多个worker_processes,目前在使用上没有问题,还支持proxy_store,也就是用它在windows服务器上建立缓存服务器会不错,适合做图片服务器哦,把麻烦的IIS丢弃算了。
资料阅读:
1 Nginx
2 apache
3 常见的WAMP集成环境
原创内容如转载请注明:来自 阿权的书房
可是要灵活rewrite和防盗链之类的,IIS可就麻烦了,一个不愿多碰的玩意
既然需要用,那就可以使用一个灵活的web服务在前面,后面放IIS,让它好好的退居二线。
一线位置的可选软件有:Nginx和apache
两者都可以提供足够的灵活性,如果还需要运行php,那不妨安装一些套件,比如:
引用
XAMPP - XAMPP是一款具有中文说明的功能全面的集成环境,XAMPP并不仅仅针对Windows,而是一个适用于Linux、Windows、Mac OS X 和Solaris 的易于安装的Apache 发行版。软件包中包含Apache 服务器、MySQL、SQLite、PHP、Perl、FileZilla FTP Server、Tomcat等等。默认安装开放了所有功能,安全性有问题,需要进行额外的安全设定。
WampServer - WampServe集成了Apache、MySQL、PHP、phpmyadmin,支持Apache的mod_rewrite,PHP扩展、Apache模块只需要在菜单“开启/关闭”上点点就搞定,省去了修改配置文件的麻烦。
AppServ - 集成了Apache、PHP、MySQL、phpMyAdmin,较为轻量。
WampServer - WampServe集成了Apache、MySQL、PHP、phpmyadmin,支持Apache的mod_rewrite,PHP扩展、Apache模块只需要在菜单“开启/关闭”上点点就搞定,省去了修改配置文件的麻烦。
AppServ - 集成了Apache、PHP、MySQL、phpMyAdmin,较为轻量。
我习惯用后者,用起来也还挺方便。
相对而言,apache的一些代理功能并非很灵活,用起来就有点复杂了。比如用正则匹配的方式条件性的进行代理,这个需要2.2.5版本以上才支持。nginx还是很不错的一个选择,代理功能非常强大,配置简洁,前端服务器的不二选择,各个大型网站都开始启用nginx,使用量风风火火的往上爬。
使用方法:
我们把IIS的默认网站停了,新建一个虚拟主机,端口号是88或者其它非80的未使用的端口即可,我们用这个作为处理asp的后端,别的不用它处理了。
当然了,下面是安装apache或者nginx。
apache和nginx作为前端,负责处理静态文件,并且把asp文件的请求交给后端。
apache的配置参考:
(httpd-vhosts.conf)
NameVirtualHost *:80
<Directory "E:/webapps/asp-test.aslibra.com">
DirectoryIndex index.htm index.html index.asp
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster@aslibra.com
DocumentRoot "E:/webapps/asp-test.aslibra.com"
ServerName asp-test.aslibra.com
ErrorLog "logs/aslibra.localhost-error.log"
CustomLog "logs/aslibra.localhost-access.log" common
#代理设置
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPassMatch .*\.asp http://127.0.0.1:88/
ProxyPassReverse / http://127.0.0.1:88/
</VirtualHost>
<Directory "E:/webapps/asp-test.aslibra.com">
DirectoryIndex index.htm index.html index.asp
Options MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerAdmin webmaster@aslibra.com
DocumentRoot "E:/webapps/asp-test.aslibra.com"
ServerName asp-test.aslibra.com
ErrorLog "logs/aslibra.localhost-error.log"
CustomLog "logs/aslibra.localhost-access.log" common
#代理设置
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPassMatch .*\.asp http://127.0.0.1:88/
ProxyPassReverse / http://127.0.0.1:88/
</VirtualHost>
Nginx的配置参考:
(判断代码,非全部)
upstream aslibra {
server 127.0.0.1:88;
}
server {
listen 80;
server_name asp-test.aslibra.com;
#启用Gzip
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/javascript application/x-javascript text/css text/plain application/xml;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip on;
root E:/webapps/asp-test.aslibra.com/;
index index.asp index.htm index.html;
#缓存控制
expires 1h;
location ~* \.(jpg|gif|png) {
expires 24h;
}
#防盗链
location ~* check_referer\.asp {
expires 0h;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://aslibra;
access_log E:/Logfiles/nginx/0909_asp.log log_referer;
valid_referers none blocked server_names;
if ($invalid_referer) {return 403;}
}
#默认的
location ~* \.asp {
expires 0h;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://aslibra;
access_log E:/Logfiles/nginx/0909_asp.log log_referer;
}
#禁止的
location ~* \.mp3 {
return 404;
}
access_log off;
}
server 127.0.0.1:88;
}
server {
listen 80;
server_name asp-test.aslibra.com;
#启用Gzip
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/javascript application/x-javascript text/css text/plain application/xml;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip on;
root E:/webapps/asp-test.aslibra.com/;
index index.asp index.htm index.html;
#缓存控制
expires 1h;
location ~* \.(jpg|gif|png) {
expires 24h;
}
#防盗链
location ~* check_referer\.asp {
expires 0h;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://aslibra;
access_log E:/Logfiles/nginx/0909_asp.log log_referer;
valid_referers none blocked server_names;
if ($invalid_referer) {return 403;}
}
#默认的
location ~* \.asp {
expires 0h;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://aslibra;
access_log E:/Logfiles/nginx/0909_asp.log log_referer;
}
#禁止的
location ~* \.mp3 {
return 404;
}
access_log off;
}
后端的asp获得用户ip的方式:
myip = Request.ServerVariables("HTTP_X_REAL_IP")
nginx的windows版本还算稳定,不过,不适用 -s reload 的方式重新加载配置文件,也不适合开多个worker_processes,目前在使用上没有问题,还支持proxy_store,也就是用它在windows服务器上建立缓存服务器会不错,适合做图片服务器哦,把麻烦的IIS丢弃算了。
资料阅读:
1 Nginx
2 apache
3 常见的WAMP集成环境
原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
原点咖啡店
北京植物园的向日葵
