Discourse 论坛搭建流程

测试环境是digitaoocean的SF机房,debian7 64bit

discourse是基于docker的程序,似乎不能安装在openvz架构的VPS,买了一堆垃圾年付的vps排不上用处 :(

安装流程:
1.mailgun 设置SMTP Routes 等

2.He.net 解析邮件DNS

3.在VPS上搭建,只需要两行命令
apt-get update&&wget -qO- https://get.docker.io/ | sh&&mkdir /var/discourse&&git clone https://github.com/discourse/discourse_docker.git /var/discourse&&cd /var/discourse&&cp samples/standalone.yml containers/app.yml&&nano containers/app.yml
编辑app.yml文件,设置email信息等
./launcher bootstrap app&&./launcher start app

4.安装ssl (待续)

5.安装完毕, http://hi.wr.tn

参考资料:
https://github.com/discourse/discourse/blob/master/docs/INSTALL-digital-ocean.md

使用nignx反向代理g o o g l e(基于lnmp 脚本)

测试的是vultr的jp 机房 debian7 x64。
1.)安装军哥的lnmp脚本
wget -c http://soft.vpser.net/lnmp/lnmp1.1-full.tar.gz && tar zxf lnmp1.1-full.tar.gz && cd lnmp1.1-full && ./debian.sh
2.)
/root/vhost.sh #军哥添加域名脚本
3.)
mkdir /home/cache/path -p #新建3个目录,放置缓存文件
mkdir /home/cache/temp -p
mkdir /data/nginx/cache/one -p
nano /usr/local/nginx/conf/nginx.conf #新增以下代码,主要是缓存相关设置,请放置于 http{ ##这里 } 中,一般加在 log_format 上面或下面均可:

client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /home/cache/temp;
proxy_cache_path /home/cache/path levels=1:2 keys_zone=cache_one:500m inactive=7d max_size=30g;
#500m是内存占用,7d是7天无访问删除,30g是缓存占具硬盘空间

4.)
nano /usr/local/nginx/conf/vhost/xxxx.conf #添加域名的配置文件

proxy_cache_path /data/nginx/cache/one levels=1:2 keys_zone=one:10m max_size=10g;
proxy_cache_key "$host$request_uri";
server {
listen 80;
server_name yourdomain.com;
rewrite ^(.*) https://yourdomain.com$1 permanent;
}

upstream google {
server 74.125.224.80:80 max_fails=3;
server 74.125.224.81:80 max_fails=3;
server 74.125.224.82:80 max_fails=3;
server 74.125.224.83:80 max_fails=3;
server 74.125.224.84:80 max_fails=3;
}
server {
listen 443;
server_name yourdomain.com;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+EXP;
ssl_prefer_server_ciphers on;
location / {
proxy_cache one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_redirect https://www.google.com/ /;
proxy_cookie_domain google.com yourdomain.com;
proxy_pass http://google;
proxy_set_header Host "www.google.com";
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2w1IQ-Maw";
sub_filter www.google.com yourdomain.com;
sub_filter_once off;
}
}

5.)到 nginx 的目录重新编译安装一下 nginx,让它支持 sub_filter
cd /root/lnmp1.1-full/nginx-1.6.0
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module
make
make install

6.)去为你的域名申请免费的ssl,获取后重命名ssl.crt ssl.key上传到目录/usr/local/nginx/conf/,修改权限777
8.)搞定后输入命令
nignx -t
显示
root@test:~/lnmp1.1-full# nginx -t nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
再重新启动你的nginx:
invoke-rc.d nginx restart
去浏览器测试下:
1
搞定。
参考资料:
http://www.vpsmm.com/page/lnmp-proxy-cc-safe/
http://www.jiechic.com/archives/set-up-a-reverse-proxy-google-search