Need help setting up 301 redirects from http to https on the following config.
Enabling return 301 https://dom1.com$request_uri; line makes too many redirects. A also tried 2 server blocks with one for 80 2nd for 443 same error.
Here is my config for vhost file:
server {
listen 80;
listen 443 ssl http2;
server_name dom1.com www.dom1.com;
# return 301 https://dom1.com$request_uri;
pagespeed off;
# use any of the following two
real_ip_header CF-Connecting-IP;
#Root Folder
root www/dom1.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
ssl_buffer_size 8k;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 30m;
#ssl_certificate /var/lib/acme/live/dom1.com/fullchain;
ssl_certificate /var/lib/acme/live/dom1.com/fullchaini_new;
#ssl_certificate_key /var/lib/acme/live/dom1.com/privkey;
ssl_certificate_key /var/lib/acme/live/dom1.com/privkey_new;
ssl_dhparam /usr/local/nginx/conf.d/dhparams.pem;
ssl_stapling on;
resolver 8.8.8.8;
ssl_stapling_verify on;
ssl_trusted_certificate /var/lib/acme/live/dom1.com/fullchain;
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
include /usr/local/nginx/www/dom1.com/nginx.conf;
#Static Files Caching
location ~ \.(css|less|js|gif|png|jpeg|jpg|ico|woff|woff2)$ {
expires 31536000s;
add_header Pragma "public";
add_header Cache-Control "max-age=31536000, public";
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}
Enabling return 301 https://dom1.com$request_uri; line makes too many redirects. A also tried 2 server blocks with one for 80 2nd for 443 same error.
Here is my config for vhost file:
server {
listen 80;
listen 443 ssl http2;
server_name dom1.com www.dom1.com;
# return 301 https://dom1.com$request_uri;
pagespeed off;
# use any of the following two
real_ip_header CF-Connecting-IP;
#Root Folder
root www/dom1.com;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
ssl_buffer_size 8k;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:50m;
ssl_session_timeout 30m;
#ssl_certificate /var/lib/acme/live/dom1.com/fullchain;
ssl_certificate /var/lib/acme/live/dom1.com/fullchaini_new;
#ssl_certificate_key /var/lib/acme/live/dom1.com/privkey;
ssl_certificate_key /var/lib/acme/live/dom1.com/privkey_new;
ssl_dhparam /usr/local/nginx/conf.d/dhparams.pem;
ssl_stapling on;
resolver 8.8.8.8;
ssl_stapling_verify on;
ssl_trusted_certificate /var/lib/acme/live/dom1.com/fullchain;
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
include /usr/local/nginx/www/dom1.com/nginx.conf;
#Static Files Caching
location ~ \.(css|less|js|gif|png|jpeg|jpg|ico|woff|woff2)$ {
expires 31536000s;
add_header Pragma "public";
add_header Cache-Control "max-age=31536000, public";
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /usr/local/nginx/conf/fastcgi_params;
}
}