/
Adding a static website
Adding a static website
This section describes the steps for adding websites, following these references:
Nginx Multisite - Documentation
Generating SSL Keys - Let's Encrypt - Documentation
Create a directory for the website HTML content.
mkdir -p /usr/share/nginx/html/newsite.comAdd default index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Site 1</title> </head> <body> <h1>Helo vino</h1> </body> </html>
Change to /etc/nginx
Create sites-available and sites-enabled
mkdir /etc/nginx/sites-enabled mkdir /etc/nginx/sites-available
Add sites-enabled support, by adding this line after (include /etc/nginx/conf.d/*.conf;)
include /etc/nginx/sites-enabled/*.conf;
Comment out the default server section
#server { # listen 80; # listen [::]:80; # server_name _; # root /usr/share/nginx/www/html; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # error_page 404 /404.html; # location = /404.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } #}
Restart the webserver
systemctl restart nginx
Create the website configuration file (sites-available/newsite.com.conf)
server { listen 80; listen [::]:80; # virtual server name i.e. domain name # server_name site1.server.test; # document root # root /usr/share/nginx/test.server.site1/html; # log files access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; # Directives to send expires headers and turn off 404 error logging. # location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; } }
Activate the site
cd sites-enabled ln -s ../sites-available/martianwinefederation.org.conf
Test everything and restart
[sites-enabled]$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful [sites-enabled]$ sudo systemctl restart nginx
Add an SSL certificate with certbot
sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email mtb@costaflores.com -d ferment.openvino.org
Remove the section that causes loops
#if ($host = ferment.openvino.org) { # return 301 https://$host$request_uri; #} # managed by Certbot
Related content
Configuring wordpress
Configuring wordpress
More like this
Delaying start of nginx
Delaying start of nginx
More like this
viniswap.costaflores.com
viniswap.costaflores.com
More like this
Viniswap 1.0
Viniswap 1.0
More like this