<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_22.04_Nginx_File_Sharing_without_DNS</id>
	<title>Ubuntu 22.04 Nginx File Sharing without DNS - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.completenoobs.com/noobs/index.php?action=history&amp;feed=atom&amp;title=Ubuntu_22.04_Nginx_File_Sharing_without_DNS"/>
	<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Nginx_File_Sharing_without_DNS&amp;action=history"/>
	<updated>2026-04-30T02:31:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Nginx_File_Sharing_without_DNS&amp;diff=426&amp;oldid=prev</id>
		<title>Noob: Created page with &quot;==No DNS using IP and SelfSigned Certs==  ===Update system=== &lt;code&gt;apt update &amp;&amp; apt upgrade -y&lt;/code&gt;&lt;br \&gt;   ===Install NGINX=== &lt;code&gt;apt install nginx -y&lt;/code&gt;&lt;br&gt;  You should now be able to see the &lt;b&gt;Welcome to nginx!&lt;/b&gt; site on your subdomain (or just use server ip address).&lt;br&gt; Only &lt;b&gt;http&lt;/b&gt; will work as we have not yet setup are &lt;b&gt;https&lt;/b&gt;&lt;br&gt;   ===Create keys for encrypted https connection===  Note: If you are just building a quick website to test this...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.completenoobs.com/noobs/index.php?title=Ubuntu_22.04_Nginx_File_Sharing_without_DNS&amp;diff=426&amp;oldid=prev"/>
		<updated>2023-05-11T19:47:01Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;==No DNS using IP and SelfSigned Certs==  ===Update system=== &amp;lt;code&amp;gt;apt update &amp;amp;&amp;amp; apt upgrade -y&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;   ===Install NGINX=== &amp;lt;code&amp;gt;apt install nginx -y&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;  You should now be able to see the &amp;lt;b&amp;gt;Welcome to nginx!&amp;lt;/b&amp;gt; site on your subdomain (or just use server ip address).&amp;lt;br&amp;gt; Only &amp;lt;b&amp;gt;http&amp;lt;/b&amp;gt; will work as we have not yet setup are &amp;lt;b&amp;gt;https&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;   ===Create keys for encrypted https connection===  Note: If you are just building a quick website to test this...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==No DNS using IP and SelfSigned Certs==&lt;br /&gt;
&lt;br /&gt;
===Update system===&lt;br /&gt;
&amp;lt;code&amp;gt;apt update &amp;amp;&amp;amp; apt upgrade -y&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Install NGINX===&lt;br /&gt;
&amp;lt;code&amp;gt;apt install nginx -y&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You should now be able to see the &amp;lt;b&amp;gt;Welcome to nginx!&amp;lt;/b&amp;gt; site on your subdomain (or just use server ip address).&amp;lt;br&amp;gt;&lt;br /&gt;
Only &amp;lt;b&amp;gt;http&amp;lt;/b&amp;gt; will work as we have not yet setup are &amp;lt;b&amp;gt;https&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Create keys for encrypted https connection===&lt;br /&gt;
&lt;br /&gt;
Note: If you are just building a quick website to test this out you can use &amp;lt;b&amp;gt;Blank&amp;lt;/b&amp;gt; (just press enter) for all fields and it will still work.&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
quick explanation:&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;openssl&amp;#039;&amp;#039;&amp;#039;: This command invokes the OpenSSL tool, which is a software library that provides a variety of cryptographic functions and utilities.&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;req&amp;#039;&amp;#039;&amp;#039;: This is a subcommand of OpenSSL that is used for creating and managing X.509 certificate signing requests (CSRs) and self-signed certificates.&lt;br /&gt;
:*    -&amp;#039;&amp;#039;&amp;#039;x509&amp;#039;&amp;#039;&amp;#039;: This option specifies that the output should be a self-signed X.509 certificate rather than a CSR.&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;-nodes&amp;#039;&amp;#039;&amp;#039;: This option specifies that the private key should not be encrypted with a password, allowing for automatic startup of services that use SSL/TLS.&lt;br /&gt;
:*    -days 365: This option specifies the number of days that the certificate will be valid for before it expires.&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;-newkey rsa:4096&amp;#039;&amp;#039;&amp;#039;: This option generates a new RSA private key with a key length of 4096 bits, which provides a higher level of security than shorter key lengths.&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;-keyout /etc/ssl/private/nginx-selfsigned.key&amp;#039;&amp;#039;&amp;#039;: This option specifies the path and filename of the private key file that will be generated by OpenSSL.&lt;br /&gt;
:*    &amp;#039;&amp;#039;&amp;#039;-out /etc/ssl/certs/nginx-selfsigned.crt&amp;#039;&amp;#039;&amp;#039;: This option specifies the path and filename of the self-signed certificate file that will be generated by OpenSSL.&lt;br /&gt;
&lt;br /&gt;
Overall, this command generates a self-signed SSL/TLS certificate and private key that can be used to secure an Nginx web server. The certificate and key are saved to the specified locations for use in the Nginx server configuration. It&amp;#039;s important to note that while self-signed certificates can provide some level of encryption for your web traffic, they do not provide any form of authentication or verification of identity, and should not be used in production environments where security is a top priority.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
/etc/ssl/private/nginx-selfsigned.key&amp;lt;br&amp;gt;&lt;br /&gt;
/etc/ssl/certs/nginx-selfsigned.crt&lt;br /&gt;
&lt;br /&gt;
===Create diffhelman===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
You can upgrade from 2048 to 4096 but it might take a while.&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /etc/nginx/snippets/ssl-params.conf&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Nginx configuration directives related to SSL/TLS:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ssl_protocols TLSv1.2;&lt;br /&gt;
#This directive specifies the SSL/TLS protocols that the server will use for secure connections. In this case, only TLS version 1.2 is allowed.&lt;br /&gt;
&lt;br /&gt;
ssl_prefer_server_ciphers on;&lt;br /&gt;
#This directive tells the server to prefer the ciphers specified by the server over those requested by the client.&lt;br /&gt;
&lt;br /&gt;
ssl_ciphers &amp;#039;ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL !LOW !DSS !MD5 !RC4 !EXP !PSK !SRP !CAMELLIA !SEED&amp;#039;;&lt;br /&gt;
#This directive specifies the SSL/TLS ciphers that the server will use for secure connections. These ciphers prioritize the use of elliptic curve cryptography (ECDHE) for key exchange and advanced encryption algorithms such as AES256 and CHACHA20-POLY1305 for encryption.&lt;br /&gt;
&lt;br /&gt;
ssl_ecdh_curve secp384r1;&lt;br /&gt;
#This directive specifies the elliptic curve Diffie-Hellman (ECDH) curve that the server will use for key exchange. In this case, the secp384r1 curve is used.&lt;br /&gt;
&lt;br /&gt;
ssl_session_cache shared:SSL:10m;&lt;br /&gt;
ssl_session_tickets off;&lt;br /&gt;
#These directives configure SSL session caching, which can improve performance by allowing the server to reuse SSL session parameters for multiple connections. The ssl_session_cache directive specifies the type of session cache to use, and the ssl_session_tickets directive specifies whether session tickets should be used.&lt;br /&gt;
&lt;br /&gt;
# need to turn ssl_stapling off for selfsigned or will get errors in /var/log/nginx/error.log&lt;br /&gt;
ssl_stapling off;&lt;br /&gt;
ssl_stapling_verify off;&lt;br /&gt;
#These directives configure OCSP stapling, which can improve security by allowing the server to provide proof of the SSL/TLS certificate&amp;#039;s validity without requiring the client to contact the certificate authority. The ssl_stapling directive specifies whether stapling should be used, and the ssl_stapling_verify directive specifies whether the server should verify the OCSP response from the certificate authority.&lt;br /&gt;
&lt;br /&gt;
resolver 8.8.8.8 80.80.80.80 valid=300s;&lt;br /&gt;
resolver_timeout 5s;&lt;br /&gt;
#These directives configure DNS resolution for OCSP stapling. The resolver directive specifies the DNS servers to use for resolving OCSP requests, and the valid parameter specifies the duration for which DNS responses will be cached. The resolver_timeout directive specifies the timeout value for DNS resolution.&lt;br /&gt;
&lt;br /&gt;
add_header Strict-Transport-Security &amp;quot;max-age=63072000; includeSubdomains&amp;quot;;&lt;br /&gt;
add_header X-Frame-Options DENY;&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
#These directives add security-related HTTP headers to responses sent by the server. The Strict-Transport-Security header specifies that SSL/TLS should always be used for connections to the server, and the X-Frame-Options and X-Content-Type-Options headers help protect against clickjacking and MIME sniffing attacks, respectively.&lt;br /&gt;
&lt;br /&gt;
ssl_dhparam /etc/ssl/certs/dhparam.pem;&lt;br /&gt;
#This directive specifies the location of the Diffie-Hellman parameters file used for SSL/TLS key exchange. The ssl_dhparam directive is used to specify the path to the file that contains the Diffie-Hellman parameters.&lt;br /&gt;
&lt;br /&gt;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;&lt;br /&gt;
#  self-signed certificate file&lt;br /&gt;
&lt;br /&gt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;&lt;br /&gt;
# private key file &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Nginx====&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /etc/nginx/sites-available/default&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;b&amp;gt;MAKE SURE TO CHANGE IP 12.34.56.78 to YOUR servers Public IP address&amp;lt;/b&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
	listen 80 default_server;&lt;br /&gt;
	listen [::]:80 default_server;&lt;br /&gt;
	server_name 12.34.56.78; ## change ip to match your server ip&lt;br /&gt;
	return 302 https://$server_name$request_uri;&lt;br /&gt;
}&lt;br /&gt;
server {&lt;br /&gt;
&lt;br /&gt;
	# SSL configuration&lt;br /&gt;
	#&lt;br /&gt;
	listen 443 ssl default_server;&lt;br /&gt;
	listen [::]:443 ssl default_server;&lt;br /&gt;
&lt;br /&gt;
	include snippets/ssl-params.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	# Add index.php to the list if you are using PHP&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
&lt;br /&gt;
	server_name _;&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		# First attempt to serve request as file, then&lt;br /&gt;
		# as directory, then fall back to displaying a 404.&lt;br /&gt;
		try_files $uri $uri/ =404;&lt;br /&gt;
		# To allow browsing of directory &lt;br /&gt;
		autoindex on;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Restart Nginx====&lt;br /&gt;
&amp;lt;code&amp;gt; systemctl restart nginx&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Allow Nginx pass firewall====&lt;br /&gt;
&amp;lt;code&amp;gt;ufw allow 80/tcp&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;ufw allow 443/tcp&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create a Directory to share store files====&lt;br /&gt;
&amp;lt;code&amp;gt;mkdir /var/www/html/files&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Create an html file====&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /var/www/html/index.html&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Files For Download&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;files&amp;quot;&amp;gt;Click here for are latest files&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Transfer Files to Sharing Directory==&lt;br /&gt;
NOTE: [[Scp_only|If you are receiving file from another server (setup server to send with script and ssh-keys), you may wish to create another account which can only receive &amp;#039;&amp;#039;&amp;#039;scp&amp;#039;&amp;#039;&amp;#039; to path]]&lt;br /&gt;
&lt;br /&gt;
===scp===&lt;br /&gt;
Check [[SCP_Examples|SCP_Examples]] for more examples:&amp;lt;br&amp;gt;&lt;br /&gt;
To send direct from MediaWiki server (Example file &amp;#039;xmlDump-03-03-2023&amp;#039;)&amp;lt;br&amp;gt;&lt;br /&gt;
Will be prompted to enter password:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;scp /path/to/file2send &amp;lt;user&amp;gt;@&amp;lt;server_address&amp;gt;:/var/www/html/files/&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Example:&amp;lt;code&amp;gt;scp /path/to/file2send ubuntu@111.222.33.444:/var/www/html/files/&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===sshfs===&lt;br /&gt;
[[Sshfs_ubuntu|Read the sshfs page for more info]]&amp;lt;br&amp;gt;&lt;br /&gt;
Can be useful if you are transferring a large number of files from your computer to server and want to use the GUI file explorer.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
NOTE:replace $USER with your user account (Example: mine is &amp;#039;ubunix&amp;#039; so i will replace &amp;#039;$USER&amp;#039; with &amp;#039;ubunix&amp;#039;) &amp;lt;br&amp;gt;&lt;br /&gt;
Install sshfs on your computer&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt install sshfs&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Create a Directory you are going to mount remote server directory to:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;mkdir /home/$USER/ServerMount&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;sudo sshfs -o allow_other,default_permissions &amp;lt;user&amp;gt;@&amp;lt;server_address&amp;gt;:/var/www/html/files/ /home/$USER/ServerMount/&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
To umount use:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;sudo umount /home/$USER/ServerMount&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===sftp===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Rsync===&lt;br /&gt;
&lt;br /&gt;
===syncthing===&lt;br /&gt;
&lt;br /&gt;
===FreeFileSync===&lt;br /&gt;
&lt;br /&gt;
===Seafile===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Require Username and Password to view website/files (Optional - Placed here for educational reasons)==&lt;br /&gt;
&amp;lt;code&amp;gt;apt install apache2-utils&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
In your &amp;lt;code&amp;gt;/etc/nginx/sites-available/default&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Append the lines(see before and after files to see where):&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auth_basic &amp;quot;Hello Please Login&amp;quot;;&lt;br /&gt;
auth_basic_user_file /etc/nginx/.htpasswd;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/nginx/sites-available/default&amp;lt;/code&amp;gt;: Before&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
# You should look at the following URL&amp;#039;s in order to grasp a solid understanding&lt;br /&gt;
# of Nginx configuration files in order to fully unleash the power of Nginx.&lt;br /&gt;
# https://www.nginx.com/resources/wiki/start/&lt;br /&gt;
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/&lt;br /&gt;
# https://wiki.debian.org/Nginx/DirectoryStructure&lt;br /&gt;
#&lt;br /&gt;
# In most cases, administrators will remove this file from sites-enabled/ and&lt;br /&gt;
# leave it as reference inside of sites-available where it will continue to be&lt;br /&gt;
# updated by the nginx packaging team.&lt;br /&gt;
#&lt;br /&gt;
# This file will automatically load configuration files provided by other&lt;br /&gt;
# applications, such as Drupal or Wordpress. These applications will be made&lt;br /&gt;
# available underneath a path with that package name, such as /drupal8.&lt;br /&gt;
#&lt;br /&gt;
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.&lt;br /&gt;
##&lt;br /&gt;
&lt;br /&gt;
# Default server configuration&lt;br /&gt;
#&lt;br /&gt;
server {&lt;br /&gt;
	listen 80 default_server;&lt;br /&gt;
	listen [::]:80 default_server;&lt;br /&gt;
&lt;br /&gt;
	# SSL configuration&lt;br /&gt;
	#&lt;br /&gt;
	# listen 443 ssl default_server;&lt;br /&gt;
	# listen [::]:443 ssl default_server;&lt;br /&gt;
	#&lt;br /&gt;
	# Note: You should disable gzip for SSL traffic.&lt;br /&gt;
	# See: https://bugs.debian.org/773332&lt;br /&gt;
	#&lt;br /&gt;
	# Read up on ssl_ciphers to ensure a secure configuration.&lt;br /&gt;
	# See: https://bugs.debian.org/765782&lt;br /&gt;
	#&lt;br /&gt;
	# Self signed certs generated by the ssl-cert package&lt;br /&gt;
	# Don&amp;#039;t use them in a production server!&lt;br /&gt;
	#&lt;br /&gt;
	# include snippets/snakeoil.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	# Add index.php to the list if you are using PHP&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
&lt;br /&gt;
	server_name _;&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		# First attempt to serve request as file, then&lt;br /&gt;
		# as directory, then fall back to displaying a 404.&lt;br /&gt;
		try_files $uri $uri/ =404;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	# pass PHP scripts to FastCGI server&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ \.php$ {&lt;br /&gt;
	#	include snippets/fastcgi-php.conf;&lt;br /&gt;
	#&lt;br /&gt;
	#	# With php-fpm (or other unix sockets):&lt;br /&gt;
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;&lt;br /&gt;
	#	# With php-cgi (or other tcp sockets):&lt;br /&gt;
	#	fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
	# deny access to .htaccess files, if Apache&amp;#039;s document root&lt;br /&gt;
	# concurs with nginx&amp;#039;s one&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ /\.ht {&lt;br /&gt;
	#	deny all;&lt;br /&gt;
	#}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Virtual Host configuration for example.com&lt;br /&gt;
#&lt;br /&gt;
# You can move that to a different file under sites-available/ and symlink that&lt;br /&gt;
# to sites-enabled/ to enable it.&lt;br /&gt;
#&lt;br /&gt;
#server {&lt;br /&gt;
#	listen 80;&lt;br /&gt;
#	listen [::]:80;&lt;br /&gt;
#&lt;br /&gt;
#	server_name example.com;&lt;br /&gt;
#&lt;br /&gt;
#	root /var/www/example.com;&lt;br /&gt;
#	index index.html;&lt;br /&gt;
#&lt;br /&gt;
#	location / {&lt;br /&gt;
#		try_files $uri $uri/ =404;&lt;br /&gt;
#	}&lt;br /&gt;
#}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
&lt;br /&gt;
	# SSL configuration&lt;br /&gt;
	#&lt;br /&gt;
	# listen 443 ssl default_server;&lt;br /&gt;
	# listen [::]:443 ssl default_server;&lt;br /&gt;
	#&lt;br /&gt;
	# Note: You should disable gzip for SSL traffic.&lt;br /&gt;
	# See: https://bugs.debian.org/773332&lt;br /&gt;
	#&lt;br /&gt;
	# Read up on ssl_ciphers to ensure a secure configuration.&lt;br /&gt;
	# See: https://bugs.debian.org/765782&lt;br /&gt;
	#&lt;br /&gt;
	# Self signed certs generated by the ssl-cert package&lt;br /&gt;
	# Don&amp;#039;t use them in a production server!&lt;br /&gt;
	#&lt;br /&gt;
	# include snippets/snakeoil.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	# Add index.php to the list if you are using PHP&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
    server_name xml.completenoobs.com; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		# First attempt to serve request as file, then&lt;br /&gt;
		# as directory, then fall back to displaying a 404.&lt;br /&gt;
		try_files $uri $uri/ =404;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	# pass PHP scripts to FastCGI server&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ \.php$ {&lt;br /&gt;
	#	include snippets/fastcgi-php.conf;&lt;br /&gt;
	#&lt;br /&gt;
	#	# With php-fpm (or other unix sockets):&lt;br /&gt;
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;&lt;br /&gt;
	#	# With php-cgi (or other tcp sockets):&lt;br /&gt;
	#	fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
	# deny access to .htaccess files, if Apache&amp;#039;s document root&lt;br /&gt;
	# concurs with nginx&amp;#039;s one&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ /\.ht {&lt;br /&gt;
	#	deny all;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot&lt;br /&gt;
    listen 443 ssl; # managed by Certbot&lt;br /&gt;
    ssl_certificate /etc/letsencrypt/live/xml.completenoobs.com/fullchain.pem; # managed by Certbot&lt;br /&gt;
    ssl_certificate_key /etc/letsencrypt/live/xml.completenoobs.com/privkey.pem; # managed by Certbot&lt;br /&gt;
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot&lt;br /&gt;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
server {&lt;br /&gt;
    if ($host = xml.completenoobs.com) {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
    } # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	listen 80 ;&lt;br /&gt;
	listen [::]:80 ;&lt;br /&gt;
    server_name xml.completenoobs.com;&lt;br /&gt;
    return 404; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;toccolours mw-collapsible mw-collapsed&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;/etc/nginx/sites-available/default&amp;lt;/code&amp;gt;: After&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-collapsible-content&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
##&lt;br /&gt;
# You should look at the following URL&amp;#039;s in order to grasp a solid understanding&lt;br /&gt;
# of Nginx configuration files in order to fully unleash the power of Nginx.&lt;br /&gt;
# https://www.nginx.com/resources/wiki/start/&lt;br /&gt;
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/&lt;br /&gt;
# https://wiki.debian.org/Nginx/DirectoryStructure&lt;br /&gt;
#&lt;br /&gt;
# In most cases, administrators will remove this file from sites-enabled/ and&lt;br /&gt;
# leave it as reference inside of sites-available where it will continue to be&lt;br /&gt;
# updated by the nginx packaging team.&lt;br /&gt;
#&lt;br /&gt;
# This file will automatically load configuration files provided by other&lt;br /&gt;
# applications, such as Drupal or Wordpress. These applications will be made&lt;br /&gt;
# available underneath a path with that package name, such as /drupal8.&lt;br /&gt;
#&lt;br /&gt;
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.&lt;br /&gt;
##&lt;br /&gt;
&lt;br /&gt;
# Default server configuration&lt;br /&gt;
#&lt;br /&gt;
server {&lt;br /&gt;
	listen 80 default_server;&lt;br /&gt;
	listen [::]:80 default_server;&lt;br /&gt;
&lt;br /&gt;
	# SSL configuration&lt;br /&gt;
	#&lt;br /&gt;
	# listen 443 ssl default_server;&lt;br /&gt;
	# listen [::]:443 ssl default_server;&lt;br /&gt;
	#&lt;br /&gt;
	# Note: You should disable gzip for SSL traffic.&lt;br /&gt;
	# See: https://bugs.debian.org/773332&lt;br /&gt;
	#&lt;br /&gt;
	# Read up on ssl_ciphers to ensure a secure configuration.&lt;br /&gt;
	# See: https://bugs.debian.org/765782&lt;br /&gt;
	#&lt;br /&gt;
	# Self signed certs generated by the ssl-cert package&lt;br /&gt;
	# Don&amp;#039;t use them in a production server!&lt;br /&gt;
	#&lt;br /&gt;
	# include snippets/snakeoil.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	# Add index.php to the list if you are using PHP&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
&lt;br /&gt;
	server_name _;&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		# First attempt to serve request as file, then&lt;br /&gt;
		# as directory, then fall back to displaying a 404.&lt;br /&gt;
		try_files $uri $uri/ =404;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	# pass PHP scripts to FastCGI server&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ \.php$ {&lt;br /&gt;
	#	include snippets/fastcgi-php.conf;&lt;br /&gt;
	#&lt;br /&gt;
	#	# With php-fpm (or other unix sockets):&lt;br /&gt;
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;&lt;br /&gt;
	#	# With php-cgi (or other tcp sockets):&lt;br /&gt;
	#	fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
	# deny access to .htaccess files, if Apache&amp;#039;s document root&lt;br /&gt;
	# concurs with nginx&amp;#039;s one&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ /\.ht {&lt;br /&gt;
	#	deny all;&lt;br /&gt;
	#}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Virtual Host configuration for example.com&lt;br /&gt;
#&lt;br /&gt;
# You can move that to a different file under sites-available/ and symlink that&lt;br /&gt;
# to sites-enabled/ to enable it.&lt;br /&gt;
#&lt;br /&gt;
#server {&lt;br /&gt;
#	listen 80;&lt;br /&gt;
#	listen [::]:80;&lt;br /&gt;
#&lt;br /&gt;
#	server_name example.com;&lt;br /&gt;
#&lt;br /&gt;
#	root /var/www/example.com;&lt;br /&gt;
#	index index.html;&lt;br /&gt;
#&lt;br /&gt;
#	location / {&lt;br /&gt;
#		try_files $uri $uri/ =404;&lt;br /&gt;
#	}&lt;br /&gt;
#}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
&lt;br /&gt;
	# SSL configuration&lt;br /&gt;
	#&lt;br /&gt;
	# listen 443 ssl default_server;&lt;br /&gt;
	# listen [::]:443 ssl default_server;&lt;br /&gt;
	#&lt;br /&gt;
	# Note: You should disable gzip for SSL traffic.&lt;br /&gt;
	# See: https://bugs.debian.org/773332&lt;br /&gt;
	#&lt;br /&gt;
	# Read up on ssl_ciphers to ensure a secure configuration.&lt;br /&gt;
	# See: https://bugs.debian.org/765782&lt;br /&gt;
	#&lt;br /&gt;
	# Self signed certs generated by the ssl-cert package&lt;br /&gt;
	# Don&amp;#039;t use them in a production server!&lt;br /&gt;
	#&lt;br /&gt;
	# include snippets/snakeoil.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	# Add index.php to the list if you are using PHP&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
    server_name xml.completenoobs.com; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		# First attempt to serve request as file, then&lt;br /&gt;
		# as directory, then fall back to displaying a 404.&lt;br /&gt;
		try_files $uri $uri/ =404;&lt;br /&gt;
		# To allow browsing of directory&lt;br /&gt;
		autoindex on;&lt;br /&gt;
		auth_basic &amp;quot;Hello Please Login&amp;quot;;&lt;br /&gt;
		auth_basic_user_file /etc/nginx/.htpasswd;&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	# pass PHP scripts to FastCGI server&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ \.php$ {&lt;br /&gt;
	#	include snippets/fastcgi-php.conf;&lt;br /&gt;
	#&lt;br /&gt;
	#	# With php-fpm (or other unix sockets):&lt;br /&gt;
	#	fastcgi_pass unix:/run/php/php7.4-fpm.sock;&lt;br /&gt;
	#	# With php-cgi (or other tcp sockets):&lt;br /&gt;
	#	fastcgi_pass 127.0.0.1:9000;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
	# deny access to .htaccess files, if Apache&amp;#039;s document root&lt;br /&gt;
	# concurs with nginx&amp;#039;s one&lt;br /&gt;
	#&lt;br /&gt;
	#location ~ /\.ht {&lt;br /&gt;
	#	deny all;&lt;br /&gt;
	#}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot&lt;br /&gt;
    listen 443 ssl; # managed by Certbot&lt;br /&gt;
    ssl_certificate /etc/letsencrypt/live/xml.completenoobs.com/fullchain.pem; # managed by Certbot&lt;br /&gt;
    ssl_certificate_key /etc/letsencrypt/live/xml.completenoobs.com/privkey.pem; # managed by Certbot&lt;br /&gt;
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot&lt;br /&gt;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
server {&lt;br /&gt;
    if ($host = xml.completenoobs.com) {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
    } # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	listen 80 ;&lt;br /&gt;
	listen [::]:80 ;&lt;br /&gt;
    server_name xml.completenoobs.com;&lt;br /&gt;
    return 404; # managed by Certbot&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Create a login Username and Password to view your website===&lt;br /&gt;
&lt;br /&gt;
Add user; change &amp;lt;b&amp;gt;user1&amp;lt;/b&amp;gt; to username of your choice; you will be prompted for password.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;htpasswd -c /etc/nginx/.htpasswd user1&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;b&amp;gt;-c&amp;lt;/b&amp;gt; flag is only needed the first time to create the file &amp;lt;b&amp;gt;/etc/nginx/.htpasswd&amp;lt;/b&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add second user; the same method is used to add has many users has you want.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;htpasswd /etc/nginx/.htpasswd user2&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;br \&amp;gt;&lt;br /&gt;
To update or change passwd for user, repeat command with username of account you wish to change; enter new password.&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;htpasswd /etc/nginx/.htpasswd user1&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Restart Nginx:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;systemctl restart nginx&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
And try site.&lt;br /&gt;
&lt;br /&gt;
===Fail2Ban to Block IP&amp;#039;s Which Enter Incorrect Username and/or Password===&lt;br /&gt;
Install Fail2Ban:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;apt install fail2ban&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /etc/fail2ban/jail.local&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Note: Can append to the very bottom of the page.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Reject Connections that failed username password&lt;br /&gt;
_action_tcp_udp = %(banaction)s[name=%(__name__)s-tcp, protocol=&amp;quot;tcp&amp;quot;, port=&amp;quot;%(port)s&amp;quot;, blocktype=&amp;quot;REJECT --reject-with tcp-reset&amp;quot;, chain=&amp;quot;%(chain)s&amp;quot;, actname=%(banaction)s-tcp]&lt;br /&gt;
    %(banaction)s[name=%(__name__)s-udp, protocol=&amp;quot;udp&amp;quot;, port=&amp;quot;%(port)s&amp;quot;, blocktype=&amp;quot;REJECT --reject-with icmp-port-unreachable&amp;quot;, chain=&amp;quot;%(chain)s&amp;quot;, actname=%(banaction)s-udp]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
actionx = %(_action_tcp_udp)s&lt;br /&gt;
&lt;br /&gt;
[nginx-cup]&lt;br /&gt;
#the name in brackets above is what you use for status&lt;br /&gt;
#   fail2ban-client status nginx-cup&lt;br /&gt;
enabled = true&lt;br /&gt;
filter = nginx-correct-up&lt;br /&gt;
port = http,https&lt;br /&gt;
logpath = /var/log/nginx/error.log&lt;br /&gt;
findtime = 3m&lt;br /&gt;
bantime = 3m&lt;br /&gt;
maxretry = 3&lt;br /&gt;
#ignoreip = &amp;lt;your-ipaddress&amp;gt;&lt;br /&gt;
#Note: Can find your ipaddress using `curl ifconfig.me` or visit `whatismyip.com`&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /etc/fail2ban/filter.d/nginx-correct-up.conf&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
[Definition]&lt;br /&gt;
failregex = client:\s&amp;lt;HOST&amp;gt;&lt;br /&gt;
ignoreregex =&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Check Fail2Ban for errors===&lt;br /&gt;
&amp;lt;code&amp;gt;fail2ban-client -d&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===restart nginx and fail2ban so updated setting can take effect===&lt;br /&gt;
&amp;lt;code&amp;gt;systemctl restart fail2ban.service&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;systemctl restart nginx.service&amp;lt;/code&amp;gt;&amp;lt;br \&amp;gt;&lt;br /&gt;
And test.&lt;br /&gt;
&lt;br /&gt;
===Remove need for username and password===&lt;br /&gt;
Comment out (or delete) the following lines from your nginx config file:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;$EDITOR /etc/nginx/sites-available/default&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
auth_basic &amp;quot;Hello Please Login&amp;quot;;&lt;br /&gt;
auth_basic_user_file /etc/nginx/.htpasswd;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Can comment out lines by placing a &amp;#039;#&amp;#039; in front.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#auth_basic &amp;quot;Hello Please Login&amp;quot;;&lt;br /&gt;
#auth_basic_user_file /etc/nginx/.htpasswd;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Restart Nginx:&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;systemctl restart nginx&amp;lt;/code&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Script for Server==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot; line&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Update and upgrade packages&lt;br /&gt;
apt update &amp;amp;&amp;amp; apt upgrade -y&lt;br /&gt;
&lt;br /&gt;
# Install nginx and apache2-utils&lt;br /&gt;
apt install nginx apache2-utils -y&lt;br /&gt;
&lt;br /&gt;
# Set up UFW rules&lt;br /&gt;
ufw allow 80/tcp&lt;br /&gt;
ufw allow 443/tcp&lt;br /&gt;
&lt;br /&gt;
# Create self-signed SSL certificate&lt;br /&gt;
openssl req -x509 -nodes -days 365 -newkey rsa:4096 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt&lt;br /&gt;
&lt;br /&gt;
# Generate Diffie-Hellman parameters&lt;br /&gt;
openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048&lt;br /&gt;
&lt;br /&gt;
# Get server IP address&lt;br /&gt;
server_ip=$(curl -s ifconfig.me)&lt;br /&gt;
&lt;br /&gt;
# Create an SSL configuration snippet&lt;br /&gt;
cat &amp;gt; /etc/nginx/snippets/ssl-params.conf &amp;lt;&amp;lt;EOL&lt;br /&gt;
ssl_protocols TLSv1.2;&lt;br /&gt;
&lt;br /&gt;
ssl_ciphers &amp;#039;ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:!aNULL:!eNULL !LOW !DSS !MD5 !RC4 !EXP !PSK !SRP !CAMELLIA !SEED&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
ssl_ecdh_curve secp384r1;&lt;br /&gt;
&lt;br /&gt;
ssl_session_cache shared:SSL:10m;&lt;br /&gt;
ssl_session_tickets off;&lt;br /&gt;
&lt;br /&gt;
ssl_stapling off;&lt;br /&gt;
ssl_stapling_verify off;&lt;br /&gt;
&lt;br /&gt;
resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
resolver_timeout 5s;&lt;br /&gt;
&lt;br /&gt;
add_header Strict-Transport-Security &amp;quot;max-age=63072000; includeSubdomains&amp;quot;;&lt;br /&gt;
add_header X-Frame-Options DENY;&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
ssl_dhparam /etc/ssl/certs/dhparam.pem;&lt;br /&gt;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;&lt;br /&gt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;&lt;br /&gt;
EOL&lt;br /&gt;
&lt;br /&gt;
# Get username and password for basic authentication&lt;br /&gt;
read -p &amp;quot;Enter a username for basic authentication: &amp;quot; username&lt;br /&gt;
read -sp &amp;quot;Enter a password for basic authentication: &amp;quot; password&lt;br /&gt;
echo&lt;br /&gt;
&lt;br /&gt;
# Create .htpasswd file&lt;br /&gt;
htpasswd -cb /etc/nginx/.htpasswd &amp;quot;$username&amp;quot; &amp;quot;$password&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Replace the default Nginx server configuration&lt;br /&gt;
cat &amp;gt; /etc/nginx/sites-available/default &amp;lt;&amp;lt;EOL&lt;br /&gt;
server {&lt;br /&gt;
	listen 80 default_server;&lt;br /&gt;
	listen [::]:80 default_server;&lt;br /&gt;
	server_name $server_ip;&lt;br /&gt;
	return 302 https://\$server_name\$request_uri;&lt;br /&gt;
}&lt;br /&gt;
server {&lt;br /&gt;
	listen 443 ssl default_server;&lt;br /&gt;
	listen [::]:443 ssl default_server;&lt;br /&gt;
&lt;br /&gt;
	include snippets/ssl-params.conf;&lt;br /&gt;
&lt;br /&gt;
	root /var/www/html;&lt;br /&gt;
&lt;br /&gt;
	index index.html index.htm index.nginx-debian.html;&lt;br /&gt;
&lt;br /&gt;
	server_name _;&lt;br /&gt;
&lt;br /&gt;
	auth_basic &amp;quot;Hello Please Login&amp;quot;;&lt;br /&gt;
	auth_basic_user_file /etc/nginx/.htpasswd;&lt;br /&gt;
&lt;br /&gt;
	location / {&lt;br /&gt;
		try_files \$uri \$uri/ =404;&lt;br /&gt;
		autoindex on;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
EOL&lt;br /&gt;
&lt;br /&gt;
# Update the server_name directive with the server_ip obtained from ifconfig.me&lt;br /&gt;
sed -i &amp;quot;s/\$server_ip/$server_ip/g&amp;quot; /etc/nginx/sites-available/default&lt;br /&gt;
&lt;br /&gt;
# Restart Nginx&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
# Create directory for files&lt;br /&gt;
mkdir /var/www/html/files&lt;br /&gt;
&lt;br /&gt;
# Create index.html file&lt;br /&gt;
cat &amp;gt; /var/www/html/index.html &amp;lt;&amp;lt;EOL&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Files For Download&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&amp;quot;files&amp;quot;&amp;gt;Click here for our latest files&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
EOL&lt;br /&gt;
&lt;br /&gt;
# Inform the user of the server IP address&lt;br /&gt;
echo &amp;quot;You can visit your server at https://$server_ip&amp;quot;&lt;br /&gt;
echo &amp;quot;Transfer files to $server_ip:/var/www/html/files&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Noob</name></author>
	</entry>
</feed>