标签类目:Apache

Apache 记录代理后的用户来源ip

分类:Apache前端nginx代理设置:

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

后端apache设置:

LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\"\"%{User-Agent}i\"" common

就可以接收到源ip了。

Apache 在代理后显示正确的用户IP

分类:Apacheapache日志中默认有%h来指定来访客户端你的ip地址,但是如果客户端使用了代理上网则%h获得的ip地址会不准。可以设定 X-Forwarded-For 参数来获取客户端真实的ip地址

对于使用了反向代理的客户端,跟踪真实的ip地址

  1. %{X-Forwarded-For}i
  2.  
  3. LogFormat "%{X-Forwarder-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" linuxanyproxy
  4. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  5.  
  6. SetEnvIf X-Forwarder-For "^.*\..*\..*\..*" is-forwarder
  7.  
  8. CustomLog logs/access_log combined env=!is-forwarder
  9. CustomLog logs/access_log linuxanyproxy env=is-forwarder

继续阅读 »

apache CGI程序的简单配置与使用

分类:Apache添加虚拟主机

<virtualhost 127.0.0.1:50001>
</virtualhost>

这里新添加了50001端口来进行监听,所以还需要添加监听端口号

Listen 50001要让程序能正常运行,还得通过配置ScriptAlias来允许服务器在指定的情况下,以CGI方式运行。

<virtualhost 127.0.0.1:50001>
ScriptAlias /cgi-bin/ /usr/local/apache/cgi-bin/
</virtualhost>

所以上述的配置会告诉apache,所以以/cgi-bin/开头的资源都会被映射到/usr/local/apache/cgi-bin/目录下,并被认为是cgi程序。然后重启服务器

继续阅读 »

给Tomcat,Apache配置gzip压缩(HTTP压缩)功能

分类:Tomcat分类:ApacheHTTP 压缩可以大大提高浏览网站的速度,它的原理是,在客户端请求网页后,从服务器端将网页文件压缩,再下载到客户端,由客户端的浏览器负责解压缩并浏览。相对于普通的浏览过程HTML ,CSS,Javascript , Text ,它可以节省40%左右的流量。更为重要的是,它可以对动态生成的,包括CGI、PHP , JSP , ASP , Servlet,SHTML等输出的网页也能进行压缩,压缩效率惊人。 继续阅读 »

mod_gzip进行Apache的HTTP压缩优化

分类:ApacheHTTP压缩对于纯文本内容可压缩至原大小的40%一下,从而提供60%以上的数据传输节约,虽然WEB服务器会因为压缩导致CPU占用的略微上升,但是可以节约大量用于传输的网络IO。对于数据压缩带来的用户浏览速度提升(让页面符合8秒定律),这点总体负载5%-10%上升是非常值得的。毕竟通过数据压缩会比通过不规范的HTML代码优化要方便得多。 继续阅读 »

Improving Page Load Times(提升页面加载时间)

分类:PHP分类:MySQL分类:ApacheThere are a number of ways to improve the amount of time it takes visitors to load your Drupal powered web site.

Measurements

There are many tools that can be used to measure page load performance on your website. Here are some that we recommend.

  1. YSlow FireFox add-on
    The YSlow FireFox add-on is maintained by Yahoo. It analyses your web page and offers a simple to understand report explaining why your website is slow to load. The tool requires that the Firebug FireFox add-on also be installed. Visit http://developer.yahoo.com/yslow/ for complete details on using the FireFox add-on. 继续阅读 »

Apache:rewrite的重写相关的参数

分类:ApacheApache mod_rewrite规则重写的标志一览

R[=code](force redirect) 强制外部重定向
强制在替代字符串加上http://thishost[:thisport]/前缀重定向到外部的URL.如果code不指定,将用缺省的302 HTTP状态码。
F(force URL to be forbidden)禁用URL,返回403HTTP状态码。
G(force URL to be gone) 强制URL为GONE,返回410HTTP状态码。
P(force proxy) 强制使用代理转发。
L(last rule) 表明当前规则是最后一条规则,停止分析以后规则的重写。
N(next round) 重新从第一条规则开始运行重写过程。
C(chained with next rule) 与下一条规则关联 继续阅读 »


返回顶部