Skip to content

Instantly share code, notes, and snippets.

@radar
Created October 10, 2012 06:58
Show Gist options
  • Save radar/3863594 to your computer and use it in GitHub Desktop.
Save radar/3863594 to your computer and use it in GitHub Desktop.
# /etc/nginx/sites-enabled/berlin
upstream spree.ryanbigg.com {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
# single worker for timing out).
# for UNIX domain socket setups:
server unix:/tmp/berlin.socket fail_timeout=0;
}
server {
# if you're running multiple servers, instead of "default" you should
# put your main domain name here
listen 80 default;
listen 443 ssl;
#ssl on;
ssl_certificate /etc/ssl/certs/spree.ryanbigg.com.crt;
ssl_certificate_key /etc/ssl/private/spree.ryanbigg.com.key;
# you could put a list of other domain names this application answers
server_name spree.ryanbigg.com;
root /home/spree/berlin/current/public;
access_log /var/log/nginx/berlin_access.log;
rewrite_log on;
location / {
#all requests are sent to the UNIX socket
proxy_pass http://spree.ryanbigg.com;
proxy_redirect off;
proxy_set_header Host $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;
}
# if the request is for a static resource, nginx should serve it directly
# and add a far future expires header to it, making the browser
# cache the resource and navigate faster over the website
# this probably needs some work with Rails 3.1's asset pipeline
location ~ ^/(spree|assets)/ {
root /home/spree/berlin/current/public;
expires max;
break;
}
}
user spree;
# Change this depending on your hardware
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
}
http {
types_hash_bucket_size 512;
types_hash_max_size 2048;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
# gzip_vary on;
gzip_proxied any;
gzip_min_length 500;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
@wickchucked
Copy link

Wanted to mention that this helped along with this key piece of information

I added this in the spree.rb in config initializers

SslRequirement.module_eval do
  protected
    def ssl_allowed?
      true
    end
end

@adamthedeveloper
Copy link

wickchucked, this did it for me as well. Thanks for posting that!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment