<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>zicjin</title>
    <link>https://ruby-china.org/zicjin</link>
    <description/>
    <language>en-us</language>
    <item>
      <title>rails 有没有类似 ImageResizer 这样根据图片请求地址的参数动态生成不同尺寸图片的类库？</title>
      <description>&lt;p&gt;&lt;a href="http://www.nuget.org/packages/ImageResizer" rel="nofollow" target="_blank"&gt;http://www.nuget.org/packages/ImageResizer&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;比如一个图片请求：&lt;a href="http://domain.com/aaa.jpg" rel="nofollow" target="_blank"&gt;http://domain.com/aaa.jpg&lt;/a&gt; 如果替换为 &lt;a href="http://domain.com/aaa.jpg?100x100" rel="nofollow" target="_blank"&gt;http://domain.com/aaa.jpg?100x100&lt;/a&gt; 就会第得到 100x100 尺寸的新图片，并缓存在服务器。&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Thu, 28 Aug 2014 13:08:38 +0800</pubDate>
      <link>https://ruby-china.org/topics/21268</link>
      <guid>https://ruby-china.org/topics/21268</guid>
    </item>
    <item>
      <title>coffee-rails 能否关闭编译时的 wapper function？也就是 --bare 参数</title>
      <description>&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="p"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;不喜欢这个默认编译参数
&lt;a href="http://coffeescript.org/#lexical-scope" rel="nofollow" target="_blank"&gt;http://coffeescript.org/#lexical-scope&lt;/a&gt;&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Sat, 23 Aug 2014 20:00:04 +0800</pubDate>
      <link>https://ruby-china.org/topics/21193</link>
      <guid>https://ruby-china.org/topics/21193</guid>
    </item>
    <item>
      <title>Capistrano 部署的错误</title>
      <description>&lt;p&gt;$ bundle exec cap production deploy&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;···
INFO[945bdbd0] Running /usr/bin/env service resque restart on d.baozoubisai.com
DEBUG[945bdbd0] Command: /usr/bin/env service resque restart
cap aborted!
SSHKit::Runner::ExecuteError: Exception &lt;span class="k"&gt;while &lt;/span&gt;executing on host d.baozoubisai.com: service &lt;span class="nb"&gt;exit &lt;/span&gt;status: 1
service stdout: Nothing written
service stderr: Nothing written
/home/vagrant/.rvm/gems/ruby-2.1.1/gems/sshkit-1.5.1/lib/sshkit/command.rb:97:in &lt;span class="sb"&gt;`&lt;/span&gt;&lt;span class="nv"&gt;exit_status&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'
···
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;这种错误该怎么调试？完全摸不着上下文。
手动执行『service resque restart』没有问题，使用的是与 cap 登录的相同的用户。&lt;/p&gt;

&lt;p&gt;deploy.rb:&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;lock&lt;/span&gt; &lt;span class="s1"&gt;'3.1.0'&lt;/span&gt;
&lt;span class="o"&gt;...&lt;/span&gt;
&lt;span class="n"&gt;namespace&lt;/span&gt; &lt;span class="ss"&gt;:deploy&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s2"&gt;"Restart unicorn and resque"&lt;/span&gt;
  &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:restart&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;invoke&lt;/span&gt; &lt;span class="s1"&gt;'deploy:passenger:restart'&lt;/span&gt;
    &lt;span class="n"&gt;invoke&lt;/span&gt; &lt;span class="s1"&gt;'deploy:resque:restart'&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="n"&gt;after&lt;/span&gt; &lt;span class="ss"&gt;:publishing&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:restart&lt;/span&gt;

  &lt;span class="n"&gt;namespace&lt;/span&gt; &lt;span class="ss"&gt;:passenger&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="ss"&gt;:restart&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;execute&lt;/span&gt; &lt;span class="ss"&gt;:touch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;release_path&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/tmp/restart.txt"&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="n"&gt;namespace&lt;/span&gt; &lt;span class="ss"&gt;:resque&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="sx"&gt;%w( start stop restart )&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="n"&gt;desc&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; resque worker"&lt;/span&gt;
      &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
        &lt;span class="n"&gt;on&lt;/span&gt; &lt;span class="n"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
          &lt;span class="n"&gt;execute&lt;/span&gt; &lt;span class="ss"&gt;:service&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:resque&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;action&lt;/span&gt;
        &lt;span class="k"&gt;end&lt;/span&gt;
      &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="sb"&gt;```shell

resque 脚本：
```&lt;/span&gt;&lt;span class="n"&gt;shell&lt;/span&gt;
&lt;span class="n"&gt;set&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;
&lt;span class="n"&gt;set&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;

&lt;span class="no"&gt;APP_ROOT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sr"&gt;/home/&lt;/span&gt;&lt;span class="n"&gt;zcj&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;www&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;baozoubisai&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;com&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;
&lt;span class="no"&gt;USER&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;zcj&lt;/span&gt;

&lt;span class="no"&gt;TIMEOUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="no"&gt;TIMEOUT&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="no"&gt;PIDFILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"$APP_ROOT/tmp/pids/resque.%d.pid"&lt;/span&gt;
&lt;span class="no"&gt;QUEUES&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*"&lt;/span&gt;
&lt;span class="no"&gt;COUNT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;

&lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="s2"&gt;"$(id -un)"&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"$USER"&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="nb"&gt;eval&lt;/span&gt; &lt;span class="vg"&gt;$1&lt;/span&gt;
  &lt;span class="k"&gt;else&lt;/span&gt;
    &lt;span class="n"&gt;su&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="vg"&gt;$USER&lt;/span&gt;
  &lt;span class="n"&gt;fi&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="s2"&gt;"$1"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt;
  &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="vg"&gt;$COUNT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;pidfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"$PIDFILE"&lt;/span&gt; &lt;span class="vg"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="s2"&gt;"$pidfile"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="s2"&gt;"kill -0 `cat $pidfile`"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
        &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Worker `cat $pidfile` alread running"&lt;/span&gt;
      &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="s2"&gt;"cd $APP_ROOT; bundle exec rake environment resque:work QUEUE=$QUEUES PIDFILE=$pidfile TERM_CHILD=1 BACKGROUND=yes RAILS_ENV=production &amp;gt; /dev/null 2&amp;gt;&amp;amp;1"&lt;/span&gt;
        &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Start worker `cat $pidfile`"&lt;/span&gt;
      &lt;span class="n"&gt;fi&lt;/span&gt;
    &lt;span class="n"&gt;done&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seq&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="vg"&gt;$COUNT&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;pidfile&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="err"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"$PIDFILE"&lt;/span&gt; &lt;span class="vg"&gt;$i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

      &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="s2"&gt;"$pidfile"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="s2"&gt;"kill -QUIT `cat $pidfile`"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
        &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Stop worker `cat $pidfile`"&lt;/span&gt;
        &lt;span class="n"&gt;run&lt;/span&gt; &lt;span class="s2"&gt;"rm $pidfile"&lt;/span&gt;
      &lt;span class="n"&gt;fi&lt;/span&gt;
    &lt;span class="n"&gt;done&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="n"&gt;restart&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;reload&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="vg"&gt;$0&lt;/span&gt; &lt;span class="n"&gt;stop&lt;/span&gt;
    &lt;span class="vg"&gt;$0&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
  &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;echo&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;amp;&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="s2"&gt;"Usage: $0 &amp;lt;start|stop|restart|reload&amp;gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="p"&gt;;;&lt;/span&gt;
&lt;span class="n"&gt;esac&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>zicjin</author>
      <pubDate>Thu, 21 Aug 2014 16:03:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/21161</link>
      <guid>https://ruby-china.org/topics/21161</guid>
    </item>
    <item>
      <title>rails server 运行时，sass-rails 有实现在文件被修改后自动编译生成 css 吗？</title>
      <description>&lt;p&gt;我的项目记得以前一直是可以在 CMD+S 文件保存后立即生成新 css 文件的。但最近不知道改了什么东西导致这个效果没有了……&lt;/p&gt;

&lt;p&gt;现在我每次修改 sass 都得执行 rake assets:precompile 后才能生效&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Sun, 17 Aug 2014 13:30:30 +0800</pubDate>
      <link>https://ruby-china.org/topics/21064</link>
      <guid>https://ruby-china.org/topics/21064</guid>
    </item>
    <item>
      <title>有没有一个 使用 Rails 4 和 Mongoid 的相对完整一点的示例项目可以给新手学习？</title>
      <description>&lt;p&gt;rtrt&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Sun, 03 Aug 2014 10:25:52 +0800</pubDate>
      <link>https://ruby-china.org/topics/20814</link>
      <guid>https://ruby-china.org/topics/20814</guid>
    </item>
    <item>
      <title>关于 “MIME type ('application/json') is not executable” 报错</title>
      <description>&lt;p&gt;我有一个 controoller 返回值是这样写的：&lt;/p&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;render&lt;/span&gt; &lt;span class="ss"&gt;:json&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;topics&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;没有写 respond_to，只输出 json。在浏览器访问这个路径返回的是正常的 json 结果。但是我在另一个页面中通过 jquery/jsonp 跨域 ajax 访问这个路径就 会出现这样的报错：
because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.&lt;/p&gt;

&lt;p&gt;我知道 jsonp 实际请求的 url 是类似这样的：
&lt;a href="http://192.168.33.10:3000/topic?callback=jQuery110207993173841387033_1405255955642&amp;amp;_=1405255955643" rel="nofollow" target="_blank"&gt;http://192.168.33.10:3000/topic?callback=jQuery110207993173841387033_1405255955642&amp;amp;_=1405255955643&lt;/a&gt;
上面这个路径在浏览器访问返回结果也是正常的。&lt;/p&gt;

&lt;p&gt;所以，这个“MIME type ('application/json') is not executable”是什么问题，怎样配置的？&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Sun, 13 Jul 2014 21:12:21 +0800</pubDate>
      <link>https://ruby-china.org/topics/20474</link>
      <guid>https://ruby-china.org/topics/20474</guid>
    </item>
    <item>
      <title>rails 部署图片资源，会被改文件名，增加了后缀，怎样避免这个改名？</title>
      <description>&lt;p&gt;因为图片多，引用这些图片的前端跟踪到这种改名非常不方便&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Fri, 27 Jun 2014 22:30:48 +0800</pubDate>
      <link>https://ruby-china.org/topics/20206</link>
      <guid>https://ruby-china.org/topics/20206</guid>
    </item>
    <item>
      <title>请教关于 InvalidAuthenticityToken 错误</title>
      <description>&lt;p&gt;提交表单就出现了 InvalidAuthenticityToken 错误。我用pry调试看到在session#new里得到的form_authenticity_token变量值和页面中登录表单内的authenticity_token hidden input值是一样的，但提交表单时进入session#creat前就报InvalidAuthenticityToken 错误了。在报错页面中 HTTP Parameters 所显示的 authenticity_token 字段也是和之前 form_authenticity_token 变量值一致的：
&lt;img src="https://l.ruby-china.com/photo/2014/26342403b182e88a7dcf55131faa2410.jpg" title="" alt=""&gt;&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Mon, 23 Jun 2014 19:17:03 +0800</pubDate>
      <link>https://ruby-china.org/topics/20126</link>
      <guid>https://ruby-china.org/topics/20126</guid>
    </item>
    <item>
      <title>求助在虚拟机里部署遇到的问题</title>
      <description>&lt;p&gt;我用 virtualbox 运行了 ubuntu-server 部署。
宿主机是 centos，nginx 配置成：&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
            listen       80;
            server_name  example.com;
            location / {
                proxy_pass http://127.0.0.1:8087/;
                proxy_redirect http://127.0.0.1:8087/ http://example.com/;
            }
        }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;然后 virtualbox 使用端口转发功能把 8087 端口转发到 ubuntu 的 80 端口：
VBoxManage modifyvm "ubuntu" --natpf1 "web,tcp,,8087,,80"&lt;/p&gt;

&lt;p&gt;现在&lt;a href="http://example.com/500.html" rel="nofollow" target="_blank"&gt;http://example.com/500.html&lt;/a&gt; 访问没问题。但是访问&lt;a href="http://example.com" rel="nofollow" target="_blank"&gt;http://example.com&lt;/a&gt; 会被跳转成&lt;a href="http://127.0.0.1:8087" rel="nofollow" target="_blank"&gt;http://127.0.0.1:8087&lt;/a&gt; 当然就不可访问了。换一个端口比如把 8087 换为 8088 也会被跳转至&lt;a href="http://127.0.0.1:8088" rel="nofollow" target="_blank"&gt;http://127.0.0.1:8088&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;这和 ruby-china 程序有什么特殊关联吗？因为以前用 virtualbox 部署过其它非 ruby 的网站没有这种问题。&lt;/p&gt;

&lt;p&gt;补充：
在 fiddler 里查看 http 请求，直接访问 &lt;a href="http://example.com" rel="nofollow" target="_blank"&gt;http://example.com&lt;/a&gt; 的 response 会出现
Location: &lt;a href="https://127.0.0.1:8088/" rel="nofollow" target="_blank"&gt;https://127.0.0.1:8088/&lt;/a&gt;
字段。访问 &lt;a href="http://example.com/500.html" rel="nofollow" target="_blank"&gt;http://example.com/500.html&lt;/a&gt; 不会有这个字段&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Wed, 11 Jun 2014 12:39:03 +0800</pubDate>
      <link>https://ruby-china.org/topics/19869</link>
      <guid>https://ruby-china.org/topics/19869</guid>
    </item>
    <item>
      <title>求助在虚拟机里部署遇到的问题</title>
      <description>&lt;p&gt;我用 virtualbox 运行了 ubuntu-server 部署。
宿主机是 centos，nginx 配置成：
server {
            listen       80;
            server_name  example.com;
            location / {
                proxy_pass &lt;a href="http://127.0.0.1:8087/" rel="nofollow" target="_blank"&gt;http://127.0.0.1:8087/&lt;/a&gt;;
            }
        }&lt;/p&gt;

&lt;p&gt;然后 virtualbox 使用端口转发功能把 8087 端口转发到 ubuntu 的 80 端口：
VBoxManage modifyvm "ubuntu" --natpf1 "web,tcp,,8087,,80"&lt;/p&gt;

&lt;p&gt;现在&lt;a href="http://example.com/500.html" rel="nofollow" target="_blank"&gt;http://example.com/500.html&lt;/a&gt; 访问没问题。但是访问&lt;a href="http://example.com" rel="nofollow" target="_blank"&gt;http://example.com&lt;/a&gt; 会被跳转成&lt;a href="http://127.0.0.1:8087" rel="nofollow" target="_blank"&gt;http://127.0.0.1:8087&lt;/a&gt; 当然就不可访问了。换一个端口比如把 8087 换为 8088 也会被跳转至&lt;a href="http://127.0.0.1:8088" rel="nofollow" target="_blank"&gt;http://127.0.0.1:8088&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;这和 ruby-china 程序有什么特殊关联吗？因为以前用 virtualbox 部署过其它非 ruby 的网站没有这种问题。&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Tue, 10 Jun 2014 23:06:45 +0800</pubDate>
      <link>https://ruby-china.org/topics/19859</link>
      <guid>https://ruby-china.org/topics/19859</guid>
    </item>
    <item>
      <title>我的 shell 每行开头连用户名 主机名都没有……可能是什么原因造成的？</title>
      <description>&lt;p&gt;&lt;img src="//l.ruby-china.com/photo/2014/19061e8e7a655a0dc881652d9767af49.jpg" title="" alt=""&gt;&lt;/p&gt;

&lt;p&gt;导致我的 tab、up、down 等按键都没有了预期效果。变成文本操作了，比如 tab 键会输出一个制表符在命令行。
其他方面使用起来倒也正常&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Fri, 09 May 2014 22:15:07 +0800</pubDate>
      <link>https://ruby-china.org/topics/19137</link>
      <guid>https://ruby-china.org/topics/19137</guid>
    </item>
    <item>
      <title>gem install nokogiri 失败: Error installing nokogiri</title>
      <description>&lt;p&gt;在项目依赖 capybara 时需要 nokogiri。安装过 libxml2 libxslt，也重装过 ruby。不知道怎么办了。&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cheneytekimbp:rails_projects zicjin&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;gem &lt;span class="nb"&gt;install &lt;/span&gt;nokogiri
Password:
Building native extensions.  This could take a &lt;span class="k"&gt;while&lt;/span&gt;...
ERROR:  Error installing nokogiri:
    ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxml2/2.8.0... OK
Running &lt;span class="s1"&gt;'configure'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxml2 2.8.0... OK
Running &lt;span class="s1"&gt;'compile'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxml2 2.8.0... OK
Running &lt;span class="s1"&gt;'install'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxml2 2.8.0... OK
Activating libxml2 2.8.0 &lt;span class="o"&gt;(&lt;/span&gt;from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxml2/2.8.0&lt;span class="o"&gt;)&lt;/span&gt;...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.1.0/ports/libxslt/1.1.26... OK
Running &lt;span class="s1"&gt;'configure'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxslt 1.1.26... OK
Running &lt;span class="s1"&gt;'compile'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxslt 1.1.26... OK
Running &lt;span class="s1"&gt;'install'&lt;/span&gt; &lt;span class="k"&gt;for &lt;/span&gt;libxslt 1.1.26... OK
Activating libxslt 1.1.26 &lt;span class="o"&gt;(&lt;/span&gt;from /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.1.0/libxslt/1.1.26&lt;span class="o"&gt;)&lt;/span&gt;...
checking &lt;span class="k"&gt;for &lt;/span&gt;libxml/parser.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;libxslt/xslt.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;libexslt/exslt.h... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;iconv_open&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in &lt;/span&gt;iconv.h... no
checking &lt;span class="k"&gt;for &lt;/span&gt;iconv_open&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nt"&gt;-liconv&lt;/span&gt;... &lt;span class="nb"&gt;yes
&lt;/span&gt;checking &lt;span class="k"&gt;for &lt;/span&gt;xmlParseDoc&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nt"&gt;-lxml2&lt;/span&gt;... no
&lt;span class="nt"&gt;-----&lt;/span&gt;
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="nb"&gt;help &lt;/span&gt;with installing dependencies.
&lt;span class="nt"&gt;-----&lt;/span&gt;
&lt;span class="k"&gt;***&lt;/span&gt; extconf.rb failed &lt;span class="k"&gt;***&lt;/span&gt;
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file &lt;span class="k"&gt;for &lt;/span&gt;more details.  You may
need configuration options.

Provided configuration options:
    &lt;span class="nt"&gt;--with-opt-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--without-opt-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--with-opt-include&lt;/span&gt;
    &lt;span class="nt"&gt;--without-opt-include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;opt&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/include
    &lt;span class="nt"&gt;--with-opt-lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-opt-lib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;opt&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/lib
    &lt;span class="nt"&gt;--with-make-prog&lt;/span&gt;
    &lt;span class="nt"&gt;--without-make-prog&lt;/span&gt;
    &lt;span class="nt"&gt;--srcdir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;.&lt;/span&gt;
    &lt;span class="nt"&gt;--curdir&lt;/span&gt;
    &lt;span class="nt"&gt;--ruby&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    &lt;span class="nt"&gt;--with-zlib-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--without-zlib-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--with-zlib-include&lt;/span&gt;
    &lt;span class="nt"&gt;--without-zlib-include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;zlib&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/include
    &lt;span class="nt"&gt;--with-zlib-lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-zlib-lib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;zlib&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/lib
    &lt;span class="nt"&gt;--with-iconv-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--without-iconv-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--with-iconv-include&lt;/span&gt;
    &lt;span class="nt"&gt;--without-iconv-include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;iconv&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/include
    &lt;span class="nt"&gt;--with-iconv-lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-iconv-lib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;iconv&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/lib
    &lt;span class="nt"&gt;--with-xml2-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xml2-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--with-xml2-include&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xml2-include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;xml2&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/include
    &lt;span class="nt"&gt;--with-xml2-lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xml2-lib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;xml2&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/lib
    &lt;span class="nt"&gt;--with-xslt-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xslt-dir&lt;/span&gt;
    &lt;span class="nt"&gt;--with-xslt-include&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xslt-include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;xslt&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/include
    &lt;span class="nt"&gt;--with-xslt-lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xslt-lib&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;xslt&lt;/span&gt;&lt;span class="p"&gt;-dir&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;/lib
    &lt;span class="nt"&gt;--with-libxslt-config&lt;/span&gt;
    &lt;span class="nt"&gt;--without-libxslt-config&lt;/span&gt;
    &lt;span class="nt"&gt;--with-pkg-config&lt;/span&gt;
    &lt;span class="nt"&gt;--without-pkg-config&lt;/span&gt;
    &lt;span class="nt"&gt;--with-libxml-2&lt;/span&gt;.0-config
    &lt;span class="nt"&gt;--without-libxml-2&lt;/span&gt;.0-config
    &lt;span class="nt"&gt;--with-libiconv-config&lt;/span&gt;
    &lt;span class="nt"&gt;--without-libiconv-config&lt;/span&gt;
    &lt;span class="nt"&gt;--with-iconvlib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-iconvlib&lt;/span&gt;
    &lt;span class="nt"&gt;--with-xml2lib&lt;/span&gt;
    &lt;span class="nt"&gt;--without-xml2lib&lt;/span&gt;

extconf failed, &lt;span class="nb"&gt;exit &lt;/span&gt;code 1

Gem files will remain installed &lt;span class="k"&gt;in&lt;/span&gt; /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.1 &lt;span class="k"&gt;for &lt;/span&gt;inspection.
Results logged to /Library/Ruby/Gems/2.0.0/extensions/universal-darwin-13/2.0.0/nokogiri-1.6.1/gem_make.out
&lt;/code&gt;&lt;/pre&gt;</description>
      <author>zicjin</author>
      <pubDate>Sat, 03 May 2014 13:50:01 +0800</pubDate>
      <link>https://ruby-china.org/topics/18975</link>
      <guid>https://ruby-china.org/topics/18975</guid>
    </item>
    <item>
      <title>部署 discourse 遇到的问题</title>
      <description>&lt;p&gt;&lt;a href="https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md" rel="nofollow" target="_blank"&gt;https://github.com/discourse/discourse/blob/master/docs/INSTALL-ubuntu.md&lt;/a&gt;
我按照这个流程部署 discourse 后访问页面得到 nginx 502，查看 thin log 得到这样的信息：
/var/www/discourse/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.4/lib/active_record/connection_adapters/postgresql_adapter.rb:848:in `initialize': fe_sendauth: no password supplied (PG::Error)&lt;/p&gt;</description>
      <author>zicjin</author>
      <pubDate>Fri, 25 Apr 2014 23:46:34 +0800</pubDate>
      <link>https://ruby-china.org/topics/18864</link>
      <guid>https://ruby-china.org/topics/18864</guid>
    </item>
  </channel>
</rss>
