Webber Webber - 1 year ago 178
PHP Question

Laravel Forge Nginx Config for SSL

I usually don't post questions until I've researched it to death on the internet. I create a CSR using Laravel Forge, add the Certificate, activate it, edit the Nginx Config using these resources:


^curl https://domain.com returns data

server {
listen 80;
server_name example.com www.example.com;
return 301 https://example.com$request_uri;

server {
listen 443 ssl;
server_name example.com www.example.com;
root /home/forge/example.com/public;

ssl_certificate /etc/nginx/ssl/vgport.com/3042/server.crt;
ssl_certificate_key /etc/nginx/ssl/vgport.com/3042/server.key;

index index.html index.htm index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;
error_log /var/log/nginx/default-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;

location ~ /\.ht {
deny all;

I do 'service nginx restart' in command line, and go to /var/log/nginx/error.log and see the following error:

'conflicting server name "" on, ignored'
'conflicting server name "www.domain.com" on, ignored'

When I visit domain.com, it gets redirected to https://domain.com with 'This webpage has a redirect loop'. Clearly the Nginx redirect isn't working somehow but I've followed all the steps.

Please let me know what additional error logs and information I should post to troubleshoot this issue. Any help would be greatly appreciated, thanks in advance.

Answer Source

okay so the problem was simpler than I thought. I was using the free cloudflare dns pointing which didn't support ssl. I switched to using the namescheap dns and it started working.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download