Skip to content

Commit

Permalink
статичесике файлы
Browse files Browse the repository at this point in the history
  • Loading branch information
melezhik committed May 28, 2012
1 parent 2d3bc98 commit e023fa8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
26 changes: 21 additions & 5 deletions nginx-fastcgi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ This definition can be used to create nginx site to run your fastcgi application
The definition takes the following params:

* name: specifies a single path (string) where nginx site config will be installed. No default, this must be specified.
* socket: specifies the port or socket on which the FastCGI-server is listening, see http://wiki.nginx.org/HttpFastcgiModule#fastcgi_pass
* static: specifies location of static files (not handled by application, but nginx)
* servers: specifies all virtual hosts to be included into site config
* cookbook: select the template source from the specified cookbook. By default it will use the cookbook where the definition is used.
* socket: specify the port or socket on which the FastCGI-server is listening, see http://wiki.nginx.org/HttpFastcgiModule#fastcgi_pass

See USAGE below.

Expand All @@ -31,19 +32,20 @@ Usage
To install nginx site config for http virtual host 127.0.0.1:80 with hostname foo.site.x:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
socket '/tmp/application.socket'
servers [
{
:ip => '127.0.0.1',
:server_name => 'foo.site.x'
}
]
socket '/tmp/application.socket'
end


To install nginx site config for https virtual host with hostname bar.site.x:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
socket '/tmp/application.socket'
servers [
{
:server_name => 'bar.site.x',
Expand All @@ -52,24 +54,24 @@ To install nginx site config for https virtual host with hostname bar.site.x:

}
]
socket '/tmp/application.socket'
end

To install nginx site config with static files handle by nginx:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
root '/var/www/MyApp/root'
socket '/tmp/application.socket'
servers [
{
:server_name => 'foo.site.x',
}
]
root '/var/www/MyApp/root'
socket '/tmp/application.socket'
end

To install nginx site config for http/https virtual hosts with hostname bar.site.x, with all http traffic get redirected to https host:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
socket '/tmp/application.socket'
servers [
{
:ip => '127.0.0.1',
Expand All @@ -83,7 +85,21 @@ To install nginx site config for http/https virtual hosts with hostname bar.site
:ssl_include_path => 'nginx_ssl_settings.conf'
}
]
end

To install nginx site config with static files handle by nginx:

nginx_fastcgi '/etc/nginx/sites-available/foo.site.conf' do
socket '/tmp/application.socket'
static => {
:location => 'static/',
:root => '/var/www/MyApp/root'
}
servers [
{
:server_name => 'foo.site.x',
}
]
end

Features
Expand Down
4 changes: 2 additions & 2 deletions nginx-fastcgi/changes.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
0.0.5
===
- changes in interafce:
- ignore :static parameters
- root parameter now in :servers array
- static parameter is not array now, and not in servers list
- add root parameter
- ignore :expire parameter

0.0.4
Expand Down
3 changes: 2 additions & 1 deletion nginx-fastcgi/definitions/nginx_fastcgi.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define :nginx_fastcgi, :root => nil do
define :nginx_fastcgi, :root => nil, :static => nil do

if params[:socket].nil? || params[:socket].empty?
message = 'you should setup socket param. '
Expand Down Expand Up @@ -28,6 +28,7 @@
source 'nginx-site.erb'
cookbook params[:cookbook] || 'nginx-fastcgi'
variables({
:static => params[:static],
:root => params[:root],
:socket => params[:socket],
:servers => params[:servers] || [],
Expand Down
6 changes: 6 additions & 0 deletions nginx-fastcgi/templates/default/nginx-site.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ server {
root <%= @root %>;
<%- end %>

<%- unless @static.nil? || @static.empty? %>
location <%= @static[:location] %> {
root <%= @static[:root] %>;
}
<%- end %>

<%- if s[:ssl] == true %>
include <%= s[:ssl_include_path] %>;
<%- end %>
Expand Down

0 comments on commit e023fa8

Please sign in to comment.