nginx代理redmine with thin

Redmine是基于Ruby开发的经典项目管理平台,功能强大。

thin, A fast and very simple Ruby web server。

本文档非操作手册只列出来关键信息,需要对ruby,redmine,nginx稍有些许了解。。。

thin 安装

1
2
3
4
5
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
bundle exec rake redmine:plugins:migrate RAILS_ENV=production --trace

gem install thin
thin install

创建logrotate配置/etc/logrotate.d/thin

1
2
3
4
5
6
7
8
9
10
11
12
13
/var/log/thin/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
/etc/init.d/thin restart >/dev/null
endscript
}

创建thin配置文件/etc/thin/redmine.yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
pid: /var/run/thin/thin.pid
group: nginx
wait: 30
timeout: 30
log: /var/log/thin/thin.log
max_conns: 1024

require: []
environment: production
max_persistent_conns: 512
servers: 4
daemonize: true
user: nginx
socket: /tmp/thin.sock
chdir: /data/DevOps/redmine

创建thin启动文件/etc/init.d/thin

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
### BEGIN INIT INFO
# Provides: thin
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: S 0 1 6
# Short-Description: thin initscript
# Description: thin
### END INIT INFO

# Original author: Forrest Robertson

# Do NOT "set -e"

DAEMON=/usr/local/rvm/gems/ruby-2.3.0/bin/thin
SCRIPT_NAME=/etc/init.d/thin
CONFIG_PATH=/etc/thin

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

case "$1" in
start)
$DAEMON start --all $CONFIG_PATH
;;
stop)
$DAEMON stop --all $CONFIG_PATH
;;
restart)
$DAEMON restart --all $CONFIG_PATH
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
exit 3
;;
esac

:

nginx配置文件 /etc/nginx/conf.d/redmine.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
upstream thin_cluster {
server unix:/tmp/thin.0.sock;
server unix:/tmp/thin.1.sock;
server unix:/tmp/thin.2.sock;
server unix:/tmp/thin.3.sock;
}
server {
listen 80;
server_name redmine.server;

#charset koi8-r;
access_log /var/log/nginx/log/redmine.access.log main;

proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#your redmine path
root /data/DevOps/redmine/public;
proxy_redirect off;

location / {
try_files $uri/index.html $uri.html $uri @cluster;
}
location @cluster {
proxy_pass http://thin_cluster;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}

参考文档

冷月无声 wechat
关注也是一种力量
-------------End of article. I appreciate whoever read and leave commends on articles.-------------

本文标题:nginx代理redmine with thin

文章作者:冷月无声

发布时间:2018年09月10日 - 23:09

最后更新:2018年09月16日 - 18:09

原始链接:https://www.lengyuewusheng.com/2018/09/10/00051_redmine-with-thin/

许可协议:本博客所有文章除特别声明外,均采用 BY-NC-SA 3.0许可协议。转载请注明出处!

感谢鼓励!