nginx - program cheatsheet
install
nginx
certbot
because no ssl means no service.
refuse
generate dhparams
sudo mkdir /etc/nginx/ssl
sudo openssl dhparam -out /etc/nginx/ssl/dhparam-2048.pem 2048
sudo openssl dhparam -out /etc/nginx/ssl/dhparam-4096.pem 4096
control nginx
test nginx configuration
create a symbolic link from an available site into an enabled site
export DOMAIN_NAME=koad.sh
sudo nano /etc/nginx/sites-available/$DOMAIN_NAME
sudo ln -s /etc/nginx/sites-available/$DOMAIN_NAME /etc/nginx/sites-enabled/$DOMAIN_NAME
obtain a certificate
let certbot obtain a certificate for us and apply the default nginx SSL configuration like follows: -->
or using webroot
pay attention
when using lets encrypt, be sure to read the output.
IMPORTANT NOTES:
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
Redirects
301 permanently
this will redirect your site, permanently
302 temporarily
this will redirect your site
from one domain to another
server {
listen 80;
hostname mywebsite.com www.mywebsite.com;
rewrite ^ http://mynewwebsite.com$request_uri? redirect;
}
from www to non-www