jeudi 21 avril 2016

HTTPS Nginx Configuration for Laravel 5

I currently have an HTTP laravel 5 app. The app is functioning fine. I'm trying to move to HTTPS. I already bough the cert, and here is my

Nginx Configuration

#HTTPS
server {

        listen 443 ssl;
        server_name my-site.com;
        ssl on;
        ssl_certificate /etc/ssl/my-site.crt;
        ssl_certificate_key /etc/ssl/my-site.key;

        root /usr/share/nginx/my-app/public;
        index index.php index.html index.htm;

        location / {

                try_files $uri/ $uri /index.php?$query_string;
        }

        location ~ \.php?$ {

                try_files $uri =404;
                include fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_read_timeout 300;
                fastcgi_intercept_errors on;
                fastcgi_split_path_info ^(.+\.php)(.*)$;
                #Prevent version info leakage
                fastcgi_hide_header X-Powered-By;
                proxy_read_timeout 300;

        }

}

#HTTP
server {

        listen 80;
        server_name my-site.com;
        rewrite ^/.*$ https://$host$request_uri? permanent;
        return 301 https://$host$request_uri;

        #More Settings ..

        #root /usr/share/nginx/my-app/public;
        #index index.php index.html index.htm;

        #location / {

                #try_files $uri/ $uri /index.php?$query_string;
        #}

        #location ~ \.php?$ {

                #try_files $uri =404;
                #include fastcgi_params;
                #fastcgi_pass 127.0.0.1:9000;
                #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                #fastcgi_read_timeout 300;
                #fastcgi_intercept_errors on;
                #fastcgi_split_path_info ^(.+\.php)(.*)$;
                ##Prevent version info leakage
                #fastcgi_hide_header X-Powered-By;
                #proxy_read_timeout 300;

        #}

}


Now with this settings, I am one step closer,

I can see that when I go to : my-site.com

It redirect to https://my-site.com

But however, I won't be able to log-in at all. It kept bouncing me back out.


Do I need to adjust anything in my Laravel route ?

How do I prevent this from happening ?

How do you guys host your Laravel app in HTTPS ?


Any hints / suggestions on this will be much appreciated !



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire