2013年3月3日 星期日

We Are Young!


這首歌的意境有很多的解釋方向,但此刻就不多說,享受那股年輕氣盛吧!最近花了兩個週末補齊了我錯估時程的工作 :P 真的,用說的都嘛比較快,不知不覺就說錯看錯估錯寫錯...


對這首歌歌詞有興趣的可以參考 fun.搖滾樂團-we-are-young-ft.-janelle-monáe-【中英歌詞】,翻的還不賴。


Tonight
We are young
So let's set the world on fire
We can burn brighter than the sun


最近周邊人的轉職、猶豫,都常讓我回顧自己去年的選擇方式,的確,就那幾個字罷了,我們還年輕,再衝動一點、再勇敢一點,再給自己多一點時間來驗證吧!


2013年3月1日 星期五

Redmine - 修正檔案上傳失敗

用 Redmine 附檔時只會看到 Internal Server Error 資訊,翻了 /var/log/apache2/error.log 後,看到了神祕句子:


Unexpected error in mod_passenger: An error occured while buffering HTTP upload data to a temporary file in /tmp/passenger.1.0.7336/generation-0/buffered_uploads. The current Apache worker process (which is running as XXX) doesn't have permissions to write to this directory. Please change the permissions for this directory (as well as all parent directories) so that it is writable by the Apache worker process, or set the 'PassengerUploadBufferDir' directive to a directory that Apache can write to.
Backtrace:
  in 'boost::shared_ptr<Passenger::BufferedUpload> Hooks::receiveRequestBody(request_rec*)' (Hooks.cpp:1321)
  in 'int Hooks::handleRequest(request_rec*)' (Hooks.cpp:585)


這時我才想到,因為我在 Apache 設定時,透過 passenger 並指定 XXX 權限跑 redmine 的,因此會碰到 XXX 無法存取 /tmp 裡頭相關的位置,解法…那就是多建立一個目錄給 redmine 使用吧 :P


$ sudo su XXX
$ mkdir /path/redmine/PassengerUploadBufferDir
$ exit
$ sudo vim /etc/apache2/conf.d/redmine
Alias /redmine "/path/redmine/public"
RailsBaseURI /redmine
<Directory /path/redmine/public>
  AssignUserId XXX XXX
  PassengerUploadBufferDir /path/redmine/PassengerUploadBufferDir
  AllowOverride all
  Options -MultiViews
</Directory>


Redmine - 修正 attachments 資料

忘記是從哪個版本開始 XD 總之,現在將 Redmine 升到 2.3.0.devel 版本,請參考官方:http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade


後來發現,以前的 attachments 都不能下載,仔細確認後,發現這跟 db schema 有關,直接翻 db 後,發現多了個欄位 disk_directory,所以在 redmine/files 規劃已經改成 redmine/files/YEAR/MONTH 的結構,故只需建立對應的結構後,在把 db 資料更新一下即可,如:


$ mkdir -p /path/redmine/files/2013/01
$ mv /path/redmine/files/* /path/redmine/files/2013/01
$ cp /path/redmine/db/production.db /path/redmine/db/production.db-backup
$ sqlite3 /path/redmine/db/production.db
sqlite> SELECT * FROM attachments WHERE ifnull(disk_directory,'') = '';
sqlite> UPDATE attachments SET disk_directory = "2013/01" WHERE ifnull(disk_directory,'') = '';


收工


2013年2月27日 星期三

[Apache] Web server 強制使用 https 連線 @ Ubuntu 12.04

最近在架服務時,突然蹦出個強制都走 https 的念頭,找了一下果然可以用 rewrite rules 來解決 :P


$ sudo a2ensite default-ssl
$ sudo a2enmode rewrite ssl
$ sudo vim default
DocumentRoot /var/www
<Directory />
  Options FollowSymLinks
  AllowOverride None


  RewriteEngine on
  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</Directory>
<Directory /var/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all


  RewriteEngine on
  RewriteCond %{SERVER_PORT} !^443$
  RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
</Directory>


2013年2月26日 星期二

[DD-WRT] Port forwarding via LAN is not working

ddwrt


最近周邊的 AP 不知不覺都刷成 DD-WRT 版本 :P 好處是設定方式越來越習慣,不用換台 AP 就要練習新的設定方式。但最近碰到一個現象,那就是設定好的 Port forwarding ,竟然在 LAN 裡頭無法使用,但在無線網路中是正常運作的。找了會,終於發現問題:r15760 breaks NAT loopback


解法就是到 Administration > Commands :


insmod ipt_mark
insmod xt_mark
iptables -t mangle -A PREROUTING -i ! `get_wanface` -d `nvram get wan_ipaddr` -j MARK --set-mark 0xd001
iptables -t nat -A POSTROUTING -m mark --mark 0xd001 -j MASQUERADE

接著按 Run commands 跟 Save Firewall 即可 :P