Navigation Menu

Skip to content

Commit

Permalink
nginx cleanups and enablement
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Jan 17, 2016
2 parents b930697 + ff97e78 commit 3c65cd0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
5 changes: 2 additions & 3 deletions README.md
Expand Up @@ -2,8 +2,7 @@

Mail Toaster v6

Start [here](https://github.com/msimerson/Mail-Toaster-6/wiki)

To build a Mail Toaster, [start here](https://github.com/msimerson/Mail-Toaster-6/wiki)

[![Build Status](https://travis-ci.org/msimerson/Mail-Toaster-6.svg?branch=master)](https://travis-ci.org/msimerson/Mail-Toaster-6)
[![Issue Count](https://codeclimate.com/github/msimerson/Mail-Toaster-6/badges/issue_count.svg)](https://codeclimate.com/github/msimerson/Mail-Toaster-6)
[![Issue Count](https://codeclimate.com/github/msimerson/Mail-Toaster-6/badges/issue_count.svg)](https://codeclimate.com/github/msimerson/Mail-Toaster-6)
8 changes: 8 additions & 0 deletions mail-toaster.sh
Expand Up @@ -183,6 +183,10 @@ get_jail_ip()
dovecot) _incr=14 ;;
redis) _incr=15 ;;
geoip) _incr=16 ;;
nginx) _incr=17 ;;
lighttpd) _incr=18 ;;
apache) _incr=19 ;;
postgres) _incr=20 ;;
stage) echo "$JAIL_NET_PREFIX.254"; return;;
esac

Expand Down Expand Up @@ -522,6 +526,10 @@ has_data_fs()
redis ) return 0;;
vpopmail ) return 0;;
webmail ) return 0;;
nginx ) return 0;;
lighttpd ) return 0;;
apache ) return 0;;
postgres ) return 0;;
esac

return 1
Expand Down
8 changes: 8 additions & 0 deletions provision-dns.sh
Expand Up @@ -66,6 +66,10 @@ include: "/usr/local/etc/unbound/toaster.conf" \
local-data: "$(get_reverse_ip dovecot) PTR dovecot"
local-data: "$(get_reverse_ip redis) PTR redis"
local-data: "$(get_reverse_ip geoip) PTR geoip"
local-data: "$(get_reverse_ip nginx) PTR nginx"
local-data: "$(get_reverse_ip lighttpd) PTR lighttpd"
local-data: "$(get_reverse_ip apache) PTR apache"
local-data: "$(get_reverse_ip postgres) PTR postgres"
local-data: "$(get_reverse_ip stage) PTR stage"
local-data: "syslog A $(get_jail_ip syslog)"
Expand All @@ -85,6 +89,10 @@ include: "/usr/local/etc/unbound/toaster.conf" \
local-data: "dovecot A $(get_jail_ip dovecot)"
local-data: "redis A $(get_jail_ip redis)"
local-data: "geoip A $(get_jail_ip geoip)"
local-data: "nginx A $(get_jail_ip nginx)"
local-data: "lighttpd A $(get_jail_ip lighttpd)"
local-data: "apache A $(get_jail_ip apache)"
local-data: "postgres A $(get_jail_ip postgres)"
local-data: "stage A $(get_jail_ip stage)"
EO_UNBOUND
Expand Down
44 changes: 19 additions & 25 deletions provision-nginx.sh
Expand Up @@ -7,51 +7,44 @@
export JAIL_CONF_EXTRA="
mount += \"$ZFS_DATA_MNT/nginx \$path/data nullfs rw 0 0\";"


install_nginx()
{
stage_pkg_install nginx dialog4ports || exit

local _nginx_conf="$STAGE_MNT/usr/local/etc/nginx/conf.d"
mkdir -p "$_nginx_conf" || exit

set_real_ip_from $(get_jail_ip haproxy);
real_ip_header X-Forwarded-For;

tell_status "building nginx with HTTP_REALIP option"
export BATCH=${BATCH:="1"}
stage_make_conf www_nginx 'www_nginx_SET=HTTP_REALIP'
stage_exec make -C /usr/ports/www/nginx build deinstall install clean
}

EO_NGINX_MT6
configure_nginx()
{
local _nginx_conf="$STAGE_MNT/usr/local/etc/nginx/conf.d"
mkdir -p "$_nginx_conf" || exit

patch -d "$STAGE_MNT/usr/local/etc/nginx" <<'EO_NGINX_CONF'
--- nginx.conf-dist 2015-11-28 23:21:55.597113000 -0800
+++ nginx.conf 2015-11-28 23:43:25.508039518 -0800
@@ -34,16 +34,13 @@
patch -d "$STAGE_MNT/usr/local/etc/nginx" <<EO_NGINX_CONF
--- nginx.conf-dist 2016-01-16 16:20:58.874842000 -0800
+++ nginx.conf 2016-01-16 16:22:36.860852732 -0800
@@ -34,7 +34,10 @@
server {
listen 80;
- server_name localhost;
+ server_name nginx;
+
+ set_real_ip_from $(get_jail_ip haproxy);
+ real_ip_header X-Forwarded-For;
#charset koi8-r;
#access_log logs/host.access.log main;
#error_page 404 /404.html;
EO_NGINX_CONF

export BATCH=${BATCH:="1"}
stage_make_conf www_nginx 'www_nginx_SET=HTTP_REALIP'
stage_exec make -C /usr/ports/www/nginx build deinstall install clean

}

start_nginx()
{
tell_status "starting nginx"
stage_sysrc nginx_enable=YES
stage_exec service nginx start

tell_status "starting nginx"
stage_sysrc nginx_enable=YES
stage_exec service nginx start
}

test_nginx()
Expand All @@ -65,6 +58,7 @@ base_snapshot_exists || exit
create_staged_fs nginx
start_staged_jail
install_nginx
configure_nginx
start_nginx
test_nginx
promote_staged_jail nginx

0 comments on commit 3c65cd0

Please sign in to comment.