I added lets encrypt certificate to my site but the conf to force https is not working. The certificate ssl works nice.
Have you tried adding the following to the relevant siteâs config file:
server {
listen 80;
server_name yoursite.com www.yoursite.com;
return 301 https://yoursite.com$request_uri;
}
Hello,
I am also facing same issue, I did add those line in nginx config use ee site edit but no luck
Can you please help me in this I want redirect non www to www including https
Thanks
You configuration in
/etc/nginx/sites-available
should look like this:
server {
server_name mydomain.com www.mydomain.com;
access_log /var/log/nginx/mydomain.com.access.log rt_cache;
error_log /var/log/nginx/mydomain.com.error.log;
#root /var/www/mydomain.com/htdocs;
listen 443 ssl http2;
ssl_certificate /var/www/22222/cert/ssl.crt;
ssl_certificate_key /var/www/22222/cert/ssl.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # do not use SSLv3 ref: POODLE
root /var/www/mydomain.com/htdocs;
index index.php index.html index.htm;
include common/wpfc.conf;
include common/wpcommon.conf;
include common/locations.conf;
include /var/www/mydomain.com/conf/nginx/*.conf;
}
server {
listen 80;
server_name mydomain.com www.mydomain.com;
return 301 https://$server_name$request_uri;
}
Hello,
I think I have all necessary stuff, please take a look
server {
server_name domain.in www.domain.in;
access_log /var/log/nginx/domain.in.access.log rt_cache; error_log /var/log/nginx/domain.in.error.log;
root /var/www/domain.in/htdocs;
index index.php index.html index.htm;
include common/php7.conf;
include common/locations-php7.conf; include /var/www/domain.in/conf/nginx/*.conf;
}
server { listen 80; server_name domain.in; return 301 $scheme://www.domain.in$request_uri; }
You need two server blocks: One listening on 443 with the following lines in it:
listen 443 ssl http2;
ssl on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
Please edit to make sure your configuration is pointing to the right certificate path. The last server block should be listening on port 80 and redirect all http requests to https Your configuration does not seem to have the necessary https configuration above.
This file contains everything you mentioned above like
listen 443 ssl http2;
ssl_certificate /var/www/22222/cert/ssl.crt; ssl_certificate_key /var/www/22222/cert/ssl.key;
Currently it redirects like https://domain.in my requirement to have redirect like this https://www.domain.in
Mmmm. I am not sure whatâs going on here but I think you should change the redirect string from:
return 301 $scheme://www.domain.in$request_uri;
To:
return 301 https://$server_name$request_uri;
$scheme contains the request scheme which in your case would be http
You can try hardcording the change to:
return 301 https://www.domain.in$request_uri;
What happens when you type in https://www.domain.in at the moment? If you are being redirected to: https://domain.in then the problem lies elsewhere. In WordPress this might mean this is the domain you selected in WordPress admin. Login and change in settings.
when I try https://www.domain.in then it works without redirecting to https://domain.in, not sure why not being redirected to www when I remove www
Easy way to replicate this issue.
Create new site with letâs encrypt ssl and it will work with only https without www Try to add new server block with www redirection like you gave me sample code
it will not work.
I fixed with
server {
listen 80;
listen [::]:80; # I added this line
server_name mydomain.com www.mydomain.com;
return 301 https://$server_name$request_uri;
}
Finally, I have fixed this.
If you create your site using ee site create command and you issue ssl using --letsencrypt then ee creates force-ssl-domain.in.conf automatically under â/etc/nginx/conf.dâ folder
You just find your config file and adjust settings thatâs it. Hard time to find it
I am having the same issue as discussed here. @hardeep, wonât the .conf get overwritten when there is an update? Is the fix an update to the âŚ/sites-available/site config? Looking for a solution - temporary bandaid is to have cloudflare handle the redirect. My other VPS has the exact same configuration with no modifications and redirects fine. Not sure why this is happening?
It shouldnât be
Fix is you have to set correct server name in conf file under â/etc/nginx/conf.dâ folder like server_name *.example.org;
After update donât forget to restart the nginx
Server name is set appropriately in the respective âforce-ssl-site.com.confâ in the â/etc/nginx/conf.dâ directory. As stated before, this directory is the same as a previous VPS that I deployed easyengine sites on, but these issues do not exist.
Content of âforce-ssl-website.com.confâ:
server { listen 80; server_name www.site.com site.com; return 301 https://site.com$request_uri; }
@botl Could you please share the output of sudo nginx -t
and sudo service nginx restart
?
p.s: You can use pastebin or similar website to share long results.
Thank you.
nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful ` service nginx restart
No output
Any ideas?
@bolt You can refer to our articles on SSL configuration,: 1, 2. Incase if they donât work, would you mind sharing the configuration of /etc/nginx/sites-available/<your-site>
, /etc/nginx/conf.d/force-ssl-<domain>.conf
and your wp-config
. As, we tried but wasnât able to reproduce the issue on our end.
Thank you.
Hi evryone, Iâm having the same problem has @botl, followed the guide and http still not redirecting to httpsâŚ
Here is : /etc/nginx/sites-available/
server {
server_name mysite.com www.mysite.com;
access_log /var/log/nginx/mysite.com.access.log rt_cache;
error_log /var/log/nginx/mysite.com.error.log;
root /var/www/mysite.com/htdocs;
index index.php index.html index.htm;
include common/w3tc.conf;
include common/wpcommon.conf;
include common/locations.conf;
include /var/www/mysite.com/conf/nginx/*.conf; }
Here is /etc/nginx/conf.d/force-ssl.conf
server { listen 80; listen [::]:80; server_name mysite.com www.mysite.com; return 301 https://mysite.com$request_uri; }
And here is wp-config:
<?php /** Enable W3 Total Cache */ define('WP_CACHE', true); // Added by W3 Total Cache // ** MySQL settings ** // /** The name of the database for WordPress */ define('DB_NAME', 'Something in there'); /** MySQL database username */ define('DB_USER', 'Something in there'); /** MySQL database password */ define('DB_PASSWORD', 'Something in there'); /** MySQL hostname */ define('DB_HOST', 'Something in there'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8'); /** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', ''); define('AUTH_KEY', '{`Something in there define('SECURE_AUTH_KEY', 'Something in there define('LOGGED_IN_KEY', 'Something in there define('NONCE_KEY', 'Something in there define('AUTH_SALT', Something in there define('SECURE_AUTH_SALT', 'Something in there define('LOGGED_IN_SALT', 'Something in there define('NONCE_SALT', Something in there $table_prefix = 'wp_'; define('WP_DEBUG', false); /* That's all! */ /** Absolute path to the WordPress directory. */ if ( !defined('ABSPATH') ) define('ABSPATH', dirname(__FILE__) . '/'); /** Sets up WordPress vars and included files. */ require_once(ABSPATH . 'wp-settings.php'); Thx for your help!