concrete5 on Nginx

Permalink
Hey everyone! Recently I've learned how to run nginx and was going to start deploying sites in it. Has anyone tried deploying c5 in nginx before? Is it pretty much the same or is there some specialties regarding it over apache.

Thanks,
David

ob7dev
 
Cahueya replied on at Permalink Best Answer Reply
I use only NGINX.

NGINX's Config looks very different, I'll explain:


This defines the expiry date for different content types. You can also set it later
map $sent_http_content_type $expires {
                default                    off;
                text/html                  epoch;
                text/css                   max;
                application/javascript     max;
                ~image/                    max;
}




Here you define to what ports and which domains the server should listen to. I use Letsencrypt certificates, so all requests to port 80 (HTTP) will be directed to the HTTPS Domain (return 301) UNLESS it is in the subdirectory of /.well-known, this will respond to HTTP calls als Letsencrypt needs that directory to renew the certificates

server {
        listen 80;
        listen [::]:80;
        server_name your-domain-name.com www.your-domain-name.com;
        location /.well-known {
                alias           /var/www/your-domain-name.com/.well-known;
                allow           all;
                default_type    "text/plain";
                }
        return 301 https://your-domain-name.com$request_uri;
        }




This is the server block for HTTPS requests that point to the server directory in which your concrete5 installation lives. (root/…)
We tell NGINX to respond to all calls that contain index.something
And afterwards we link to the Letsencrypt certs. Obviously you need to comment all that out until you got your certificates in the right place. Within the Letsencrypt lines we define which connections shall be accepted (TLSv1.2, TLSv1.1 TLSv1) and which Ciphers shall be used, as well as Diffie-Hellman-Method. You need to uncomment the "Strict Transport Security" line if you work on a dev doman.

The following location blocks define where your PHP and FastCGI sits, and this is for PHP7.0* so maybe you need to adjust for your version. Everything else should be pretty self-explanatory.


server {
        listen 443 ssl http2;
        listen [::]:443 ssl http2;
        server_name your-domain-name.com;
        root /var/www/your-domain-name.com;
        expires $expires;
        index index.php index.html index.htm index.nginx-debian.html;
        ##
        #LET'S ENCRYPT CERTIFICATES
        ##
        ssl_certificate /etc/letsencrypt/live/your-domain-name.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/your-domain-name.com/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/your-domain-name.com/chain.pem;
        ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
        ssl_ciphers EECDH+AESGCM:EDH+AESGCM:EECDH:EDH:!MD5:!RC4:!LOW:!MEDIUM:!CAMELLIA:!ECDSA:!DES:!DSS:!3DES:!NULL;


Put this into /etc/nginx/sites-available/your-domain-name.com and set a symbolic link to that file in /etc/nginx-sites-enabled. (ln -s /etc/nginx/sites-available/your-domain-name.com /etc/nginx-sites-enabled/ )

Don't forget to make your server root accessible for the nginx user (chown -R www-data:www-data /var/www/your-domain-name.com/ )

Restart nginx after that and it should be working.
mlocati replied on at Permalink Reply
mlocati
I'm using both NGINX and Apache to get the best from both. Here's my setup:http://mlocati.github.io/articles/nginx-apache-concrete5.html...
ob7dev replied on at Permalink Reply
ob7dev
I just went for a single nginx setup. I'm running the site on NixOS as a server, so the entire computer is dedicated to running one site. Each of my customers gets a vm and I deploy their site with a NixOS configuration file. I had the best luck getting concrete5 to run on nginx using the info here:https://stackoverflow.com/questions/11226624/deploying-concrete5-on-...
Then I came up with the NixOS side of things for a succesful deployment. It was so exciting see that concrete5 install screen again after being away from c5 development for almost a year!