Skip to content

Instantly share code, notes, and snippets.

@yungke
yungke / fastcgi_cache.conf
Last active February 2, 2016 14:52
Nginx fastcgi_cache 緩存加速設定
fastcgi_cache_path /dev/shm/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_path /dev/shm/life-cache levels=1:2 keys_zone=life.1798.in:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
@yungke
yungke / joomla_php2
Created January 14, 2016 06:15
joomla_string
if (function_exists('iconv') && PHP_VERSION_ID < 50600)
{
// These are settings that can be set inside code
iconv_set_encoding("internal_encoding", "UTF-8");
iconv_set_encoding("input_encoding", "UTF-8");
iconv_set_encoding("output_encoding", "UTF-8");
}
elseif (PHP_VERSION_ID >= 50600)
{
ini_set("default_charset", "UTF-8");
@yungke
yungke / 128mb_conf
Created January 4, 2016 14:17
128MB VPS 配置
user www www;
worker_processes auto;
error_log /data/wwwlogs/error_nginx.log crit;
pid /var/run/nginx.pid;
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
@yungke
yungke / gtour_ssl_conf
Created January 2, 2016 15:07
HTTPS_conf
server
{
listen 80;
server_name gtour.info www.gtour.info;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name gtour.info www.gtour.info;
@yungke
yungke / check-nginx
Last active December 29, 2015 09:15
nginx_ngx_pagespeed
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.9
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module
@yungke
yungke / apache_pagespeed.conf
Last active August 29, 2015 14:20
個別對不同虛擬主機的配置
ModPagespeed On
ModPagespeedInheritVHostConfig on
ModPagespeedFileCachePath "/var/cache/mod_pagespeed/"
ModPagespeedEnableFilters combine_css,combine_javascript
# Direct Apache to send all HTML output to the mod_pagespeed
# output handler.
AddOutputFilterByType MOD_PAGESPEED_OUTPUT_FILTER text/html
NameVirtualHost *:80
<VirtualHost *:80>
@yungke
yungke / X-Page-Speed header
Last active August 29, 2015 14:20
Wp-ffpc 在 Nginx 的 conf 檔案
[root@vps ~]# curl -I http://yourDomain.com/
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 27 Apr 2015 02:51:40 GMT
Content-Type: text/html;charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: no-store, no-cache, must-revalidate, max-age=0, post-check=0, pre-check=0
Pragma: no-cache
Expires: Mon, 27 Apr 2015 02:51:40 GMT
@yungke
yungke / discuz_application.php
Created April 24, 2015 04:08
Discuz X3.2 facebook 連結至 discuz 的錯誤修正
private function _xss_check() {
$_SERVER['REQUEST_URI'] = preg_replace("/(&|\?)fb_action(.*?)$/i", "", $_SERVER['REQUEST_URI']);
$temp = strtoupper(urldecode(urldecode($_SERVER['REQUEST_URI'])));
if(strpos($temp, '<') !== false || strpos($temp, '"') !== false || strpos($temp, 'CONTENT-TRANSFER-ENCODING') !== false) {
system_error('request_tainting');
}
return true;
}
@yungke
yungke / .htaccess
Created April 19, 2015 09:25
w3tc for Apache
# BEGIN W3TC Browser Cache
<IfModule mod_mime.c>
AddType text/css .css
AddType text/x-component .htc
AddType application/x-javascript .js
AddType application/javascript .js2
AddType text/javascript .js3
AddType text/x-js .js4
AddType text/html .html .htm
AddType text/richtext .rtf .rtx
@yungke
yungke / header_common.htm
Created April 18, 2015 22:42
Discuz! X3.2 圓形頭像
<style>
.avt img{-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
}
.bui .m img {
-moz-border-radius: 50%;
-webkit-border-radius: 50%;
border-radius: 50%;
height: 110px;