nginxでリバプロでnode.js

  • node.js
$ cat hello.js
var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(3000, '127.0.0.1');
console.log('Server running at http://127.0.0.1:3000/');
  • nginx.conf
location /node {
    proxy_pass  http://127.0.0.1:3000;
    break;
}
  • 確認
$ wget -q http://127.0.0.1:8080/node -O -
Hello World

はい、簡単な例でした。

でふぉonのサービス

# chkconfig --list | grep :on
acpid           0:off   1:off   2:on    3:on    4:on    5:on    6:off
atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
cpuspeed        0:off   1:on    2:off   3:off   4:off   5:off   6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
ip6tables       0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
irqbalance      0:off   1:off   2:off   3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
ntpdate         0:off   1:off   2:on    3:on    4:on    5:on    6:off
postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off
rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
sysstat         0:off   1:on    2:on    3:on    4:on    5:on    6:off
udev-post       0:off   1:on    2:off   3:off   4:off   5:off   6:off

acpid

ACPIによる電源管理…いらん

atd

所定した時刻にコマンドを実行する…cronでOK

cpuspeed

システムのアイドル比率に応じてCPUの動作周波数を上下させ…なくていい

ip6tables

ファイヤーウォール(IPv6版)…使わね

irqbalance

マルチCPU環境でセカンドCPU以降も割り込み処理を行え…なくてOKかな?

postfix

onなの?いらん

確認

# chkconfig --list | grep :on
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off
lvm2-monitor    0:off   1:on    2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
ntpd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
ntpdate         0:off   1:off   2:on    3:on    4:on    5:on    6:off
rsyslog         0:off   1:off   2:on    3:on    4:on    5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
sysstat         0:off   1:on    2:on    3:on    4:on    5:on    6:off
udev-post       0:off   1:on    2:off   3:off   4:off   5:off   6:off

とりあえずこんなものでOKかな?
あとは、gitとnodeとnginxとかいろいろ入れます。

SELinuxの無効

# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

iptables設定変更

FORWARDは使わないのでDROP+sshのポート10022をあける(とりあえずどっからでも)

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
# iptables -P FORWARD DROP
# iptables -A INPUT -p tcp --dport 10022 -j ACCEPT
# iptables -A INPUT -p tcp --sport 10022 -j ACCEPT
# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:10022
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:10022

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

sshのポート変更

# cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.20120330
# vi /etc/ssh/sshd_config
# diff -ub /etc/ssh/sshd_config /etc/ssh/sshd_config.20120330
--- /etc/ssh/sshd_config        2012-03-30 02:19:14.477857922 +0900
+++ /etc/ssh/sshd_config.20120330       2012-03-30 00:09:47.383921479 +0900
@@ -10,7 +10,7 @@
 # possible, but leave them commented.  Uncommented options change a
 # default value.

-Port 10022
+#Port 22
 #AddressFamily any
 #ListenAddress 0.0.0.0
 #ListenAddress ::
# service sshd restart
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]