Articles of http headers

mod_expires不设置图像到期(PNG,JPEG,GIF)

我在我的apache2.conf中使用下面的configuration <IfModule mod_expires.c> ExpiresActive On ExpiresByType image/gif "access plus 6 month" ExpiresByType image/jpg "access plus 6 month" ExpiresByType image/jpeg "access plus 6 month" ExpiresByType text/javascript "access plus 6 month" ExpiresByType text/css "access plus 6 month" ExpiresDefault "access plus 6 month" </IfModule> 它为css和js工作 curl -I example.com/assests/css/global.css Expires: Wed, 14 Jan 2015 09:28:17 GMT 但是当我curl任何图像文件 curl -I […]

在什么情况下,Apache允许不匹配的HTTP_HOST通过?

有人设法将未定义的HTTP_HOST服务器variables传递给我的应用程序脚本,从而触发一系列错误。 我很困扰,但无法复制这种行为。 我的httpd服务器使用以下参数使用基于名称的虚拟主机: ServerName example.com:80 UseCanonicalName On <VirtualHost *:80> ServerName example.com ServerAlias ftp.example.com service.example.com ErrorDocument 404 /error/404.html.var … </VirtualHost> <VirtualHost *:80> ServerName notfound.example.com ServerAlias * RedirectMatch 404 ^/(?!error) ErrorDocument 404 /error/404.html.var </VirtualHost> 我试图使用wget复制请求与以下内容: wget -dS –header='Host: ' http://example.com/?x0a/x04/x0a/x04/x06/x08/x09/… –2014-07-30 03:00:00– http://example.com/?x0a/x04/x0a/x04/x06/x08/x09/… Connecting to example.com:80… connected. —request begin— GET / HTTP/1.1 Accept: */* Host: Connection: Keep-Alive […]

HEAD请求从Linux / Ubuntu的盒子

我不知道这是否属于服务器故障。 我们的服务器上禁用了HEAD请求。 但是我们看到数以千计的HEAD请求,总是使用相同的用户代理。 “X11; Linux x86_64 chrome。 它看起来像一个Ubuntu或其他Linux机器。 你有没有看过一个Linux浏览器/ Firefox做出这样的要求? 那为什么这个特定的浏览器与Windows相同呢? 它看起来像使用的技术是HTTPstream水线。 用户代理示例: Mozilla / 5.0(X11; x86_64上的Linux i686; rv:10.0)Gecko / 20100101 Firefox / 10.0

无法结合RewriteRule和标题集

试图执行以下内容: RewriteRule \.ttf$ – [E=cors:1] Header set Access-Control-Allow-Origin "*.example.com" env=cors:1 Header set Access-Control-Allow-Origin "*.sadface.com" env=!cors:1 然后请求: $ curl -I http://www.example.com/font.ttf … Access-Control-Allow-Origin: *.sadface.com UPDATE 感谢Jenny D,我发现其他地方的重写规则是做一个本地redirect到index.php,所以我修改了以下内容: # Set CORS domain for fonts. RewriteCond %{QUERY_STRING} \.ttf RewriteRule ^(.*)$ $1 [E=cors:1] Header set Access-Control-Allow-Origin "*.example.com" env=cors:1 Header set Access-Control-Allow-Origin "*.sadface.com" env=!cors:1 这提供了以下日志条目: RewriteCond: input='q=font.ttf' pattern='\\.ttf' => matched […]

包含的重写规则不匹配

用Apache,我试图设置一个重写规则,这个规则将被包含在几个虚拟主机中。 其实这个规则文件是包含在2个虚拟主机中的。 第一个虚拟主机只包含这个重写规则(它起作用),并作为Nginx的反向代理: RewriteEngine On Include /etc/apache2/bad-referers 另一个包含一个Wordpress与W3的总caching插件与其Apache的conf和默认的WP .htaccess: RewriteEngine On RewriteCond %{HTTP_HOST} !^domain.tld$ RewriteRule ^(.*) http://domain.tld/$1 [R=301,L,QSA] Include /etc/apache2/bad-referers Include /var/www/d/domain.tld/w3tc.conf 在这种情况下,不好的引用者是不匹配的,而这个规则以[F,L]结束。 域名重写和W3总caching规则运作良好。 我真的不明白。 包含指令的顺序或位置是否重要? 我可能必须将所有这些文件的内容放在vhost指令中吗? 还是RewriteBase? (几乎)完整的虚拟主机通过/服务器信息: 在文件中: /etc/apache2/sites-enabled/domain.tld 1: <VirtualHost *:80> 7: <Directory /var/www/d/domain.tld/html/> 14: RewriteEngine On 16: RewriteCond %{HTTP_HOST} !^domain.tld$ 17: RewriteRule ^(.*) http://domain.tld/$1 [R=301,L,QSA] 在文件中: /etc/apache2/bad-referers 2: RewriteEngine on 5: […]

apache2 – 为什么caching的静态文件不会发生?

我正在努力在SugarCRM环境中caching静态文件,这不是我想要的。 我已经把它缩小到一个具体的案例,我想知道为什么这样。 在Chrome浏览器上,我试图直接访问这个url: http://hostname/cache/include/javascript/sugar_grp1_jquery.js Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4 Cache-Control:max-age=0 Connection:keep-alive Cookie:PHPSESSID=dlbb4vtum36n37teu9eqpd1pf7; sugar_user_theme=SuiteR Host:hostname If-Modified-Since:Thu, 09 Jul 2015 08:16:57 GMT If-None-Match:"6f344-51a6ce0fcb040-gzip" Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36 Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding:gzip, deflate, sdch Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4 Cache-Control:max-age=0 Connection:keep-alive Cookie:PHPSESSID=dlbb4vtum36n37teu9eqpd1pf7; sugar_user_theme=SuiteR Host:hostname If-Modified-Since:Thu, 09 Jul 2015 08:16:57 GMT If-None-Match:"6f344-51a6ce0fcb040-gzip" Upgrade-Insecure-Requests:1 User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 […]

Nginx – 错误的响应头

当安装joomla我面临一个问题与响应头相关。 在安装过程中,ajax post请求发送给服务器,响应状态是303而不是200 ! 所以Ajaxcallback不会触发和安装中断。 我认为这个问题与nginxconfiguration有关,因为我在apache本地服务器上testing它,这里没有问题。 nginx访问日志: POST /installation/index.php HTTP/1.1" 303 5 "http://…/installation/index.php" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.80 Safari/537.36" apache(本地)访问日志: "POST /joomla-test/installation/index.php HTTP/1.1" 200 286 nginxconfiguration: location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fastcgi_pass_header Status; <– tested but not work ! include fastcgi.conf; }

内容安全策略:阻止uri“关于”

我正在实施Content security policy到我的网站标题。 我目前report-only在report-only设置进行testing。 我的服务器是Apache 2.4.7 。 在制定了一些政策后,我继续看到这样的报道: "csp-report": { "document-uri": "http://www.example.com/page.html", "referrer": "", "violated-directive": "script-src 'self' http://www.google-analytics.com", "effective-directive": "script-src", "original-policy": "default-src 'self'; img-src *; report-uri https://example.com/report", "blocked-uri": "about", "status-code": 200 } 我不知道如何解决这些报告。 Page.html包含静态HTML和Google analytics script 。 about这个被封锁的uri究竟是什么? 我已阅读内容安全策略文档,但找不到任何可以解释这一点的内容。 我不能通过访问相同的浏览器types的url重现错误。

不一致的caching和过期头(杂注:nocache)

我试图让我的Apache服务器(v2.4.7)响应由浏览器和像Google这样的蜘蛛发送的If-Modified-Since头。 我在Google网站pipe理员的build议中发现了这一点。 我直到昨天才知道这一点,也不知道Apache没有回应这个头,因此也没有向浏览器或蜘蛛发送Last-Modified头。 我也注意到,从我的服务器的每一个请求发回杂注:nocache 经过大量的阅读和摆弄,我实际上已经在我的主要网站上工作了。 这只是发现php.ini中的php.ini设置调用session.cache_limiter设置为nocache,所以我把它设置为session.cache_limiter = public 重新启动服务器,瞧,该网站是给予正确的标题,它传递了各种If-Modified-Since头testing器。 现在的问题….在我所有的其他15个WordPress的网站,他们仍然发送杂注:nocache标题和主要网站上显示的其他caching标题。 所有的站点都有完全相同的configuration在他们的apache .conf文件中所有的站点在他们的.htaccess中都有完全相同的configuration所有站点都运行WordPress 我曾尝试在其他网站上设置和取消设置apache .conf文件中的标题,但他们只是被忽略。 对于我的生活,我错过了一些东西,我不知道在哪里或者什么,整天都在经历.conf和.htaccess和php.ini文件。 有什么是干扰标题,我不知道是什么。 这些是我加载的Apache模块,如果有帮助 Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) actions_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) […]

如何只从.htaccess运行一个Header指令

我有Apache 2.4.18(安全补丁),但由于托pipe限制,我不能只更改configuration文件.htaccess 。 mod_headers已启用,我只想在访问www.example.com/ (带有或不带尾部斜线)时才运行Header指令。 LocationMatch '^/$'不允许在.htaccess 。 怎么办?