Setting up Nginx + Passenger » History » Version 5
Sachar de Vries, 07/04/2013 05:58 AM
1 | 1 | Rytis Sileika | h1. Setting up Nginx + Passenger |
---|---|---|---|
2 | |||
3 | Passenger packages/repos are available at http://passenger.stealthymonkeys.com/ |
||
4 | |||
5 | |||
6 | Install packages |
||
7 | |||
8 | <pre> |
||
9 | # yum install -y nginx-passenger |
||
10 | </pre> |
||
11 | |||
12 | Create self signed certificate |
||
13 | |||
14 | <pre> |
||
15 | # cd /etc/nginx/ |
||
16 | # openssl genrsa -des3 -out server.key 1024 |
||
17 | # openssl req -new -key server.key -out server.csr |
||
18 | # cp server.key server.key.org |
||
19 | # openssl rsa -in server.key.org -out server.key |
||
20 | # openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt |
||
21 | </pre> |
||
22 | |||
23 | Make a local copy of the apps `public` directory (local to rails, as nginx/passenger doesn't seem to like symbolic links) |
||
24 | |||
25 | <pre> |
||
26 | # cd /usr/share/foreman |
||
27 | # rm public |
||
28 | # cp -a /var/lib/foreman/public . |
||
29 | </pre> |
||
30 | |||
31 | Add to `/etc/nginx/nginx.conf`: |
||
32 | |||
33 | <pre> |
||
34 | env PATH; |
||
35 | </pre> |
||
36 | |||
37 | Create foreman application config file `/etc/nginx/conf.d/foreman.conf`: |
||
38 | |||
39 | <pre> |
||
40 | server { |
||
41 | listen 443; |
||
42 | server_name _; |
||
43 | ssl on; |
||
44 | ssl_certificate /etc/nginx/server.crt; |
||
45 | ssl_certificate_key /etc/nginx/server.key; |
||
46 | 4 | Dominic Cleal | |
47 | # Verify puppetmaster clients against Puppet CA |
||
48 | ssl_crl /var/lib/puppet/ssl/ca/ca_crl.pem; |
||
49 | ssl_client_certificate /var/lib/puppet/ssl/certs/ca.pem; |
||
50 | ssl_verify_client optional; |
||
51 | ssl_verify_depth 1; |
||
52 | |||
53 | 1 | Rytis Sileika | access_log /var/log/nginx/foreman_access.log; |
54 | error_log /var/log/nginx/foreman_error.log debug; |
||
55 | root /usr/share/foreman/public; |
||
56 | 4 | Dominic Cleal | |
57 | 1 | Rytis Sileika | passenger_enabled on; |
58 | 4 | Dominic Cleal | passenger_set_cgi_param HTTPS on; |
59 | passenger_set_cgi_param SSL_CLIENT_S_DN $ssl_client_s_dn; |
||
60 | passenger_set_cgi_param SSL_CLIENT_VERIFY $ssl_client_verify; |
||
61 | |||
62 | 1 | Rytis Sileika | #location / { |
63 | #} |
||
64 | } |
||
65 | </pre> |
||
66 | 4 | Dominic Cleal | |
67 | The SSL configuration here can verify clients for SSL communications with puppetmaster scripts, as per the "Securing Communications with SSL":http://theforeman.org/manuals/1.1/index.html#5.4SecuringCommunicationswithSSL documentation. It verifies clients using the Puppet CA and passes the information to Passenger and Foreman. |
||
68 | |||
69 | This guide uses a self-signed certificate for the Foreman server, so the ENC and report scripts will need to reference the certificate generated here in the @:ssl_ca@ and @$foreman_ssl_ca@ settings. |
||
70 | 5 | Sachar de Vries | |
71 | |||
72 | h2. Nginx + Passenger with foreman 1.2 on RHEL6.x/Scientific Linux |
||
73 | |||
74 | To run both puppermaster and foreman 1.2 on the same host using nginx + passenger an upgrade to phusion passenger 4.0 is required. To not break your existing puppetmaster setup, which uses the system supplied ruby follow the following steps: |
||
75 | |||
76 | setup assumes you are upgrading from foreman 1.1 and have a working nginx-passenger setup already. |
||
77 | |||
78 | <pre> |
||
79 | the current phusion supplied rpm is still a 3 version, so using yum upgrade won't help |
||
80 | yum info passenger-release |
||
81 | Loaded plugins: security |
||
82 | Available Packages |
||
83 | Name : passenger-release |
||
84 | Arch : noarch |
||
85 | Version : 3 |
||
86 | Release : 6.el6 |
||
87 | Size : 5.5 k |
||
88 | Repo : passenger |
||
89 | Summary : Phusion Passenger release RPM/Yum repository configuration |
||
90 | URL : http://passenger.stealthymonkeys.com/ |
||
91 | License : MIT |
||
92 | Description : Phusion Passenger Yum/RPM configuration. This package contains the Yum |
||
93 | : repository configuration to install & update Phusion Passenger, as |
||
94 | : well as the GPG signing key to verify them. |
||
95 | </pre> |
||
96 | |||
97 | So instead use gem to install the correct package (as per: https://www.phusionpassenger.com/download#open_source): |
||
98 | <pre> |
||
99 | gem install passenger |
||
100 | Fetching: daemon_controller-1.1.4.gem (100%25) |
||
101 | Fetching: passenger-4.0.5.gem (100%25) |
||
102 | Successfully installed daemon_controller-1.1.4 |
||
103 | Successfully installed passenger-4.0.5 |
||
104 | 2 gems installed |
||
105 | Installing ri documentation for daemon_controller-1.1.4... |
||
106 | Installing ri documentation for passenger-4.0.5... |
||
107 | Installing RDoc documentation for daemon_controller-1.1.4... |
||
108 | Installing RDoc documentation for passenger-4.0.5... |
||
109 | </pre> |
||
110 | |||
111 | Configure nginx: |
||
112 | you might need to install some packages ( yum install libcurl-devel libcurl ) |
||
113 | <pre> |
||
114 | passenger-install-nginx-module |
||
115 | Welcome to the Phusion Passenger Nginx module installer, v4.0.5. |
||
116 | |||
117 | This installer will guide you through the entire installation process. It |
||
118 | shouldn't take more than 5 minutes in total. |
||
119 | |||
120 | Here's what you can expect from the installation process: |
||
121 | |||
122 | 1. This installer will compile and install Nginx with Passenger support. |
||
123 | 2. You'll learn how to configure Passenger in Nginx. |
||
124 | 3. You'll learn how to deploy a Ruby on Rails application. |
||
125 | |||
126 | Don't worry if anything goes wrong. This installer will advise you on how to |
||
127 | solve any problems. |
||
128 | |||
129 | Press Enter to continue, or Ctrl-C to abort. |
||
130 | |||
131 | |||
132 | -------------------------------------------- |
||
133 | |||
134 | Checking for required software... |
||
135 | |||
136 | * Checking for GNU C compiler... |
||
137 | Found: yes |
||
138 | Location: /usr/bin/gcc |
||
139 | * Checking for GNU C++ compiler... |
||
140 | Found: yes |
||
141 | Location: /usr/bin/g++ |
||
142 | * Checking for A download tool like 'wget' or 'curl'... |
||
143 | Found: yes |
||
144 | Location: /usr/bin/wget |
||
145 | * Checking for Ruby development headers... |
||
146 | Found: yes |
||
147 | Location: /usr/lib64/ruby/1.8/x86_64-linux/ruby.h |
||
148 | * Checking for OpenSSL support for Ruby... |
||
149 | Found: yes |
||
150 | * Checking for RubyGems... |
||
151 | Found: yes |
||
152 | * Checking for Rake (associated with /usr/bin/ruby)... |
||
153 | Found: yes |
||
154 | Location: /usr/bin/ruby /usr/bin/rake |
||
155 | * Checking for rack... |
||
156 | Found: yes |
||
157 | * Checking for Curl development headers with SSL support... |
||
158 | Found: yes |
||
159 | Version: libcurl 7.19.7 |
||
160 | Usable: yes |
||
161 | curl-config location: /usr/bin/curl-config |
||
162 | Supports SSL: yes |
||
163 | Header location: /usr/include/curl/curl.h |
||
164 | * Checking for OpenSSL development headers... |
||
165 | Found: yes |
||
166 | Location: /usr/include/openssl/ssl.h |
||
167 | * Checking for Zlib development headers... |
||
168 | Found: yes |
||
169 | Location: /usr/include/zlib.h |
||
170 | </pre> |
||
171 | |||
172 | Stop nginx and update /etc/init.d/nginx to use the correct binary |
||
173 | <pre> |
||
174 | vi /etc/init.d/nginx |
||
175 | #nginx="/usr/sbin/nginx" |
||
176 | nginx="/opt/nginx/sbin/nginx" |
||
177 | </pre> |
||
178 | |||
179 | Make sure passenger.conf in /etc/nginx/conf,d still points to the system pruby passenger version |
||
180 | <pre> |
||
181 | # cat passenger.conf |
||
182 | |||
183 | passenger_root /usr/lib/ruby/gems/1.8/gems/passenger-4.0.5; |
||
184 | passenger_ruby /usr/bin/ruby; |
||
185 | </pre> |
||
186 | |||
187 | Update foreman.conf (do not set the passenger_root) |
||
188 | <pre> |
||
189 | # cat foreman.conf |
||
190 | |||
191 | server { |
||
192 | passenger_ruby /usr/bin/ruby193-ruby; |
||
193 | |||
194 | ..... |
||
195 | } |
||
196 | <snip> |
||
197 | </pre> |
||
198 | |||
199 | Start nginx and verify that both puppetmaster and foreman are working |
||
200 | |||
201 | http://www.modrails.com/documentation/Users%2520guide%2520Nginx.html#_configuring_phusion_passenger has more information |