server { listen [::]:80; listen 80; # listen on both hosts server_name silvrtree.co.uk www.silvrtree.co.uk; # and redirect to the https host (declared below) # avoiding http://www -> https://www -> https:// chain. return 301 https://silvrtree.co.uk$request_uri; } server { listen [::]:443 ssl spdy; listen 443 ssl spdy; server_name silvrtree.co.uk www.silvrtree.co.uk; include secure/ssl.conf; root /var/www/silvrtree; index index.html index.htm; location / { proxy_pass http://localhost:9000; proxy_set_header Host $host; } location /couchdb/(.*)$ { rewrite /couchdb/(.*) /$1 break; proxy_pass http://127.0.0.1:5984; proxy_pass_header Accept; proxy_pass_header Server; keepalive_requests 1000; add_header 'Access-Control-Allow-Origin' '*'; proxy_redirect off; proxy_buffering off; proxy_set_header Host $host; proxy_set_header Authorization ""; # or according to server.ini proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } }