在IIS 8.5之前使用nginx。
IIS 8.5已经configuration压缩并且工作得很好。
但是当我们通过nginx(config下面)来打开它时,gzip就会丢失(从Web浏览器的angular度来看)。
第1部分:解决scheme尝试#1是在nginx上启用gzip,它从浏览器的angular度带回gzip,但现在(我们担心)要么(a)施加双gzip开销(gzip in iis,解压缩nginx,re-gzip在nginx上); 或者,(b)gzip现在在nginx上,这是不理想的(因为我们对iis有更好的控制,而且iis可以更好地决定什么是静态的,什么是dynamic的,因此caching更好等)。 解决scheme#1的configuration可以在这里看到: nginx:服务器上的gzip在代理期间丢失
附录1:每个nginx文档( https://www.nginx.com/resources/admin-guide/compression-and-decompression/):“NGINX …不会”压缩“已压缩的响应”
这是好的,因为双压缩不会发生。
第2部分:我们真正想要的是让accept-encoding头从浏览器通过nginx到iis,让iis做所有的压缩,并通过nginx传递gzip的响应,而不会在nginx上发生任何gzip开销。 我们的运行configuration如下。
问题:我们如何在nginx 1.7.9中实现第2部分?
运行反向代理configuration,剥离所有gzip(例如它似乎去除了accept-encoding头):
http { upstream sandbox_site { least_conn; # we pipe to back end on port 80 only, so that nginx handles all ssl server 192.168.2.16:80 max_fails=1 fail_timeout=60s; # sbox3-site is .2.16 } server { # This is sandbox.myapp.com block ************************************** listen 192.168.2.27:80; server_name sandbox.myapp.com; location / { proxy_pass http://sandbox_site; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } } server { # This is SSL version of sandbox.myapp.com block ************************************** listen 192.168.2.27:443 ssl; server_name sandbox.myapp.com; ssl_certificate new-sandbox-myapp-com.cer; ssl_certificate_key new-sandbox-myapp-com.key; ssl_protocols SSLv3 TLSv1; ssl_ciphers HIGH:!aNULL:!MD5; location / { proxy_pass http://sandbox_site; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }