Create a CA (certificate authority):
openssl genrsa -des3 -out jodiBooksCA.key 2048
openssl req -x509 -new -nodes -key jodiBooksCA.key -sha256 -days 730 -out jodiBooksCA.pem
The second command asks a few question. The output with answers should show something like this:
joep@PCJOEP:~$ openssl genrsa -des3 -out jodiBooksCA.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
...............................................+++++
................................................+++++
e is 65537 (0x010001)
Enter pass phrase for jodiBooksCA.key:
Verifying - Enter pass phrase for jodiBooksCA.key:
joep@PCJOEP:~$ openssl req -x509 -new -nodes -key jodiBooksCA.key -sha256 -days 730 -out jodiBooksCA.pem
Enter pass phrase for jodiBooksCA.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:NL
State or Province Name (full name) [Some-State]:North-Brabant
Locality Name (eg, city) []:Eindhoven
Organization Name (eg, company) [Internet Widgits Pty Ltd]:jodiBooks B.V.
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:jodibooks.com
Email Address []:info@jodibooks.com
Now create a signed certificate:
NAME=jodibooks.com
openssl genrsa -out $NAME.key 2048
openssl req -new -key $NAME.key -out $NAME.csr
>$NAME.ext cat <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = dev-api.$NAME
DNS.2 = dev-beauty.$NAME
DNS.3 = dev-mgmt.$NAME
DNS.4 = dev-payments.$NAME
EOF
openssl x509 -req -in $NAME.csr -CA jodiBooksCA.pem -CAkey jodiBooksCA.key -CAcreateserial -out $NAME.crt -days 730 -sha256 -extfile $NAME.ext
openssl pkcs12 -export -out $NAME.pfx -inkey $NAME.key -in $NAME.crt
Some commands ask for additional input. The output with answers should show something like this:
joep@PCJOEP:~$ NAME=jodibooks.com
joep@PCJOEP:~$ openssl genrsa -out $NAME.key 2048
Generating RSA private key, 2048 bit long modulus (2 primes)
.......................................................+++++
.....+++++
e is 65537 (0x010001)
joep@PCJOEP:~$ openssl req -new -key $NAME.key -out $NAME.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:NL
State or Province Name (full name) [Some-State]:North-Brabant
Locality Name (eg, city) []:Eindhoven
Organization Name (eg, company) [Internet Widgits Pty Ltd]:jodiBooks B.V.
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:jodibooks.com
Email Address []:info@jodibooks.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
joep@PCJOEP:~$ >$NAME.ext cat <<-EOF
> authorityKeyIdentifier=keyid,issuer
> basicConstraints=CA:FALSE
> keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
> subjectAltName = @alt_names
> [alt_names]
> DNS.1 = dev-api.$NAME
> DNS.2 = dev-beauty.$NAME
> DNS.3 = dev-mgmt.$NAME
> DNS.4 = dev-payments.$NAME
> EOF
joep@PCJOEP:~$ openssl x509 -req -in $NAME.csr -CA jodiBooksCA.pem -CAkey jodiBooksCA.key -CAcreateserial -out $NAME.crt -days 730 -sha256 -extfile $NAME.ext
Signature ok
subject=C = NL, ST = North-Brabant, L = Eindhoven, O = jodiBooks B.V., CN = jodibooks.com, emailAddress = info@jodibooks.com
Getting CA Private Key
Enter pass phrase for jodiBooksCA.key:
joep@PCJOEP:~$ openssl pkcs12 -export -out $NAME.pfx -inkey $NAME.key -in $NAME.crt
Enter Export Password:
Verifying - Enter Export Password:
brave://settings/certificates
(change brave
to chrome
or edge
depending on the exact browser you use). Now add our created CA as an authority. Select "Trust this CA to identify websites".about:preferences#privacy
. Scroll down and click “View Certificates”. Add our created CA as authority. Select "Trust this CA to identify websites".Sources:
Getting Chrome to accept self-signed localhost certificate
Create a .pfx/.p12 Certificate File Using OpenSSL - SSL.com
cert
and open "Manage computer certificates".jodiBooksCA.pem
into "Trusted Root Certification Authorities"jodibooks
.jodibooks
. Add a "http binding" to the domain/website on port 80
.IIS needs read permissions on the application files to serve the applications. It needs Full control to write new files like log files. This can be set by adding the usr IIS_IUSRS
to folder containing the application.
On main page of IIS, find “Authentication”. Click “Anonymous Authentication” and in the right hand bar click “Edit”
Then, select “Application pool identity”
There are a lot of settings in IIS that affect the speed of your website. Apply at least these:
Enable Application Initialization (optional, only for performance testing)
Enable "Cache-control Header"
14
. Increase or decrease depending on how often you update your site.Source:
https://port135.com/2019/05/17/recommendations-improve-iis-performance-fine-tuning/
Open "Virus & threat detection"
Under heading "Virus & threat protection settings" click Manage settings
Under heading "Exclusions" click Add or remove exclusions
Add folders:
C:\inetpub\temp\appPools
C:\inetpub\temp\IIS Temporary Compressed Files
C:\inetpub\wwwroot
C:\jodibooks\apps
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Config
C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Temporary ASP.NET Files
C:\Windows\Microsoft.Net\Framework\v2.0.50727\CONFIG
C:\Windows\Microsoft.Net\Framework\v4.0.3031\Config
C:\Windows\Microsoft.Net\Framework\v4.0.3031\Temporary ASP.NET Files
C:\Windows\System32\inetsrv\Config
There are many ciphers and encryption algorythms that can be used to communicate between the browser and IIS. Most of them are now deemed unsafe. To only use "safe" ones, use a tool called IISCrypto and select the Strict template.
Add user to www-data
group:
sudo usermod -aG www-data jodibooks
Create a folder for the website and make sure your user owns the folder:
sudo mkdir /var/www/test-website
sudo chown jodibooks:www-data /var/www/test-website
Create Nginx config:
sudo nano /etc/nginx/sites-available/test-website.com.conf
Copy and paste the content:
# Listen on port 443 (https)
server {
# use http2 for improved performance
listen 443 ssl http2;
# application folder location
root /var/www/test-website;
# search for thes index file types
index index.html;
# specify application domain name
server_name test-website.com;
# what to do with the request
location / {
# check if uri is valid otherwise return 404
try_files $uri $uri/ $uri.html =404;
# tell crawlers/search engines to not index this application (uncomment for test websites)
#add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
}
# error page file and location
error_page 404 /404.html;
location /404.html {
internal;
}
# static file caching
location ~* .(html|js|css|png|webp|jpg|jpeg|ico|svg|json|pdf)$ {
expires max;
log_not_found off;
access_log off;
}
# log location and file name
access_log /var/log/nginx/test-website_access.log;
error_log /var/log/nginx/test-website_error.log;
# SSL
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
# Listen on port 80 (http)
server {
# listen if a request comes in through port 80
listen 80;
server_name test-website.com;
}
Enable site by soft-linking the .conf
file in the sites-available
folder to the sites-enabled
folder:
sudo ln -s /etc/nginx/sites-available/test-website.com.conf /etc/nginx/sites-enabled/
Create two records. The actual steps are dependent on the DNS hoster of our customers' domain reseller.
Name | Type | Value |
---|---|---|
test-website.com | A | <external_ip_of_server> |
www.test-website.com | CNAME | test-website.com |
Install Certbot on the Ubuntu machine running Nginx.
Run Certbot to create a certificate:
sudo certbot --nginx
Update crontab
to automatically renew certificates (add sudo
if the user tab doesn't work):
crontab -e
Add lines:
# Renew Let's Encrypt certificates
0 0 1 * * certbot renew
Certbot will update your test-website.conf
Nginx file. It will look something like this now:
# Listen on port 443 (https)
server {
# use http2 for improved performance
listen 443 ssl http2;
# application folder location
root /var/www/test-website;
# search for thes index file types
index index.html;
# specify application domain name
server_name test-website.com;
# what to do with the request
location / {
# check if uri is valid otherwise return 404
try_files $uri $uri/ $uri.html =404;
# tell crawlers/search engines to not index this application (uncomment for test websites)
#add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
}
# error page file and location
error_page 404 /404.html;
location /404.html {
internal;
}
# static file caching
location ~* .(html|js|css|png|webp|jpg|jpeg|ico|svg|json|pdf)$ {
expires max;
log_not_found off;
access_log off;
}
# log location and file name
access_log /var/log/nginx/test-website_access.log;
error_log /var/log/nginx/test-website_error.log;
# SSL
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
ssl_certificate /etc/letsencrypt/live/test-booking.jodibeauty.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/test-booking.jodibeauty.com/privkey.pem; # managed by Certbot
}
# Listen on port 80 (http)
server {
# if a http request comes in through port 80 redirect 301 with https
if ($host = teamcity.jodibooks.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
# listen if a request comes in through port 80
listen 80;
server_name test-website.com;
return 404; # managed by Certbot
}