Disclaimer: I have posted this on Stackoverflow as well as I thought it may have fit better there. The link to the question is below if someone would like to answer there.
--
I have the following:
domain.com - many urls that have no need for SSL (I would like to use Varnish to cache all of these) domain.com/shop - all urls should be using SSL (No need for Varnish, I would like to listen on port 443)
I am basically looking for the best way to configure the server to cache all uris that are not in need of SSL as this has to run on port 443. All port 8080 requests are going to Varnish and working correctly. In addition I want to make sure and non-ssl request is sent to domain.com (including www requests). I have done this before but for some reason the SSL in the equation is making things complicated.
My configuration is as follows:
`server {
listen 8080;
server_name domain.com;
root /var/www/domain.com/public_html;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
# Tried using to shut off http on all non SSL needed urls.
fastcgi_param HTTPS off;
}
}
server {
listen 443 ssl;
server_name domain.com;
ssl_certificate /etc/nginx/keys/www.domain.com.chained.crt;
ssl_certificate_key /etc/nginx/keys/domain.com.key;
access_log /var/www/domain.com/logs/access.log ;
error_log /var/www/domain.com/logs/error.log ;
root /var/www/domain.com/public_html;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
#https will not work without this.
fastcgi_param HTTPS on;
}
}