<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.seaoffate.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=192.168.100.9</id>
	<title>Sea of Fate - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.seaoffate.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=192.168.100.9"/>
	<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php/Special:Contributions/192.168.100.9"/>
	<updated>2026-06-06T01:10:35Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=253</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=253"/>
		<updated>2025-03-16T12:49:22Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Initial Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The host plum.seaoffate.net will be at an IP address of production.20. The purpose will be to show photos using Piwigo. The main premise is that plum will have a SSD hard drive for it&#039;s OS as normal but it will have a large hard drive from the ZFS Proxmox storage to store the photos and video. We can add the hd as soon as the VM is created but leave it to be formatted and mounted later.&lt;br /&gt;
&lt;br /&gt;
==Initial Setup==&lt;br /&gt;
&lt;br /&gt;
The first things we need to do is to install Apache and configure the webserver, as soon as that is done we should setup the reverse proxy on Raisin. The good news is that we have some scripts to do that as it is just boiler plate stuff all we need to say here is that the website will be called photo or more precisely photo.seaoffate.net. To use the wonderful scripts we must first copy them from Lemon so open a terminal on lemon and cd to ~/templates once that is done enter the command&lt;br /&gt;
 scp create_apache_config.sh lamp_client_install.sh nigel@plum:~/&lt;br /&gt;
This will copy the files to the home dir of nigel (if SSH is not ready yet on plum look here). When the two are copied they will need to be made executable and make sure they are owned by the set user so login to plum and &lt;br /&gt;
 sudo chown nigel:nigel create_apache_config.sh&lt;br /&gt;
 sudo chown nigel:nigel lamp_client_install.sh&lt;br /&gt;
 sudo chmod 755 lamp_client_install.sh&lt;br /&gt;
 sudo chmod 755 create_apache_config.sh&lt;br /&gt;
Now that we have the first scripts we can execute them&lt;br /&gt;
 ./lamp_client_install.sh&lt;br /&gt;
and then setup the websites with the other script&lt;br /&gt;
 ./create_apache_config.sh photo&lt;br /&gt;
This script will create the configs for the hostname(plum) and the parameter in this case photo. We will get 6 configs both the http and https for plum.seaofffate.local and photo.seaoffate.local and photo.seaoffate.net. We will should check that the seaoffate.crt is in the /etc/ssl/certs dir&lt;br /&gt;
 ls -l /etc/ssl/certs/&lt;br /&gt;
If it is missing then we should get the cert and key and mv it to the /etc/ssl/ dirs it should be called &amp;quot;seaoffate&amp;quot; (.crt &amp;amp; .key) to match the Apache configs that we just created. The next thing we need to do is get the piwigo zip file. Probably the best thing is to get it downloaded on to one of the desktop Linux VMs and scp it to this at the home dir. We will need to copy the zip to the public_html (best to cp rather than mv in case we need to redo the install and we would just delete everything in public_html). First we install zip, then cp the zip file then cd to where we want to extract to&lt;br /&gt;
 sudo apt install zip&lt;br /&gt;
 sudo cp piwigo-15.4.0.zip /var/www/plum.seaoffate.local&lt;br /&gt;
 cd /var/www/plum.seaoffate.local&lt;br /&gt;
Then delete the existing public_html&lt;br /&gt;
 sudo rm -rf /var/www/plum.seaoffate.local/public_html&lt;br /&gt;
and then unzip the file with&lt;br /&gt;
 unzip piwigo-15.4.0.zip -d .&lt;br /&gt;
This will create a dir called piwigo and so we rename it to public_html&lt;br /&gt;
 sudo mv piwigo /var/www/plum.seaoffate.local/public_html&lt;br /&gt;
so we now should have all of the files extracted in to the docroot of our website we now need to change the ownersip to the apache user&lt;br /&gt;
 sudo chown -R www-data:www-data /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
Before we can proceed with the installation at a web browser we have to create a database and for piwigo to use so ssh to mandarin and start a MySQL session with&lt;br /&gt;
 sudo mysql -u root -p&lt;br /&gt;
at the mysql&amp;gt; prompt we need to create the database&lt;br /&gt;
 CREATE DATABASE piwigo_db;&lt;br /&gt;
and then the user with privileges to the database, we will restrict this user to the plum host only &lt;br /&gt;
 CREATE USER &#039;piwigo_user&#039;@&#039;192.168.100.22&#039; IDENTIFIED BY &#039;your_strong_password&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON piwigo_db.* TO &#039;piwigo_user&#039;@&#039;192.168.100.22&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES; &lt;br /&gt;
 exit?&lt;br /&gt;
Armed with our newly created database and user we can now start the web installation so we need to go get a web browser to https://photo.seaoffate.local. if that takes us to the nginix holding page we will need to setup raisin to do the reverse proxy thing or we could continue from a client inside the Pfsense but if we do that we still have to do the raisin set up at some point. so we may as well do so now so SSH to raisin &lt;br /&gt;
 cd /etc/nginx/sites-available&lt;br /&gt;
 sudo cp wiki.conf photo.conf&lt;br /&gt;
 sudo cp wiki.seaoffate.local.ssl.conf photo.seaoffate.local.ssl.conf&lt;br /&gt;
 sudo cp wiki.seaoffate.net.conf photo.seaoffate.net.conf&lt;br /&gt;
Then modify them to replace the servernames and ip addresses. While it is not pretty it does work and the scripts that we had generated forwarding loops so we can&#039;t use them. It looks like the reverse proxy was redirecting as well as the origin so it was causing a problem for browsers, we should only have the origin browser do any redirect between 80 and 443. Once this is done proceed to the web browser part of the piwigi installation. Keep a record of passwords in a password manager. Most of the install is now done. we could use the application as is but we would run out of storage for photos before too long so we will add a big hard drive to the installation mounting it inside public_html.&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=252</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=252"/>
		<updated>2025-03-16T12:42:56Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Initial Setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The host plum.seaoffate.net will be at an IP address of production.20. The purpose will be to show photos using Piwigo. The main premise is that plum will have a SSD hard drive for it&#039;s OS as normal but it will have a large hard drive from the ZFS Proxmox storage to store the photos and video. We can add the hd as soon as the VM is created but leave it to be formatted and mounted later.&lt;br /&gt;
&lt;br /&gt;
==Initial Setup==&lt;br /&gt;
&lt;br /&gt;
The first things we need to do is to install Apache and configure the webserver, as soon as that is done we should setup the reverse proxy on Raisin. The good news is that we have some scripts to do that as it is just boiler plate stuff all we need to say here is that the website will be called photo or more precisely photo.seaoffate.net. To use the wonderful scripts we must first copy them from Lemon so open a terminal on lemon and cd to ~/templates once that is done enter the command&lt;br /&gt;
 scp create_apache_config.sh lamp_client_install.sh nigel@plum:~/&lt;br /&gt;
This will copy the files to the home dir of nigel (if SSH is not ready yet on plum look here). When the two are copied they will need to be made executable and make sure they are owned by the set user so login to plum and &lt;br /&gt;
 sudo chown nigel:nigel create_apache_config.sh&lt;br /&gt;
 sudo chown nigel:nigel lamp_client_install.sh&lt;br /&gt;
 sudo chmod 755 lamp_client_install.sh&lt;br /&gt;
 sudo chmod 755 create_apache_config.sh&lt;br /&gt;
Now that we have the first scripts we can execute them&lt;br /&gt;
 ./lamp_client_install.sh&lt;br /&gt;
and then setup the websites with the other script&lt;br /&gt;
 ./create_apache_config.sh photo&lt;br /&gt;
This script will create the configs for the hostname(plum) and the parameter in this case photo. We will get 6 configs both the http and https for plum.seaofffate.local and photo.seaoffate.local and photo.seaoffate.net. We will should check that the seaoffate.crt is in the /etc/ssl/certs dir&lt;br /&gt;
 ls -l /etc/ssl/certs/&lt;br /&gt;
If it is missing then we should get the cert and key and mv it to the /etc/ssl/ dirs it should be called &amp;quot;seaoffate&amp;quot; (.crt &amp;amp; .key) to match the Apache configs that we just created. The next thing we need to do is get the piwigo zip file. Probably the best thing is to get it downloaded on to one of the desktop Linux VMs and scp it to this at the home dir. We will need to copy the zip to the public_html (best to cp rather than mv in case we need to redo the install and we would just delete everything in public_html). First we install zip, then cp the zip file then cd to where we want to extract to&lt;br /&gt;
 sudo apt install zip&lt;br /&gt;
 sudo cp piwigo-15.4.0.zip /var/www/plum.seaoffate.local&lt;br /&gt;
 cd /var/www/plum.seaoffate.local&lt;br /&gt;
Then delete the existing public_html&lt;br /&gt;
 sudo rm -rf /var/www/plum.seaoffate.local/public_html&lt;br /&gt;
and then unzip the file with&lt;br /&gt;
 unzip piwigo-15.4.0.zip -d .&lt;br /&gt;
This will create a dir called piwigo and so we rename it to public_html&lt;br /&gt;
 sudo mv piwigo /var/www/plum.seaoffate.local/public_html&lt;br /&gt;
so we now should have all of the files extracted in to the docroot of our website we now need to change the ownersip to the apache user&lt;br /&gt;
 sudo chown -R www-data:www-data /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
Before we can proceed with the installation at a web browser we have to create a database and for piwigo to use so ssh to mandarin and start a MySQL session with&lt;br /&gt;
 sudo mysql -u root -p&lt;br /&gt;
at the mysql&amp;gt; prompt we need to create the database&lt;br /&gt;
 CREATE DATABASE piwigo_db;&lt;br /&gt;
and then the user with privileges to the database, we will restrict this user to the plum host only &lt;br /&gt;
 CREATE USER &#039;piwigo_user&#039;@&#039;192.168.100.22&#039; IDENTIFIED BY &#039;your_strong_password&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON piwigo_db.* TO &#039;piwigo_user&#039;@&#039;192.168.100.22&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES; &lt;br /&gt;
 exit?&lt;br /&gt;
Armed with our newly created database and user we can now start the web installation so we need to go get a web browser to https://photo.seaoffate.local. if that takes us to the nginix holding page we will need to setup raisin to do the reverse proxy thing or we could continue from a client inside the Pfsense but if we do that we still have to do the raisin set up at some point. so we may as well do so now so SSH to raisin &lt;br /&gt;
 cd /etc/nginx/sites-available&lt;br /&gt;
 sudo cp wiki.conf photo.conf&lt;br /&gt;
 sudo cp wiki.seaoffate.local.ssl.conf photo.seaoffate.local.ssl.conf&lt;br /&gt;
 sudo cp wiki.seaoffate.net.conf photo.seaoffate.net.conf&lt;br /&gt;
Then modify them to replace the servernames and ip addresses. While it is not pretty it does work and the scripts that we had generated forwarding loops so we can&#039;t use them. It looks like the reverse proxy was redirecting as well as the origin so it was causing a problem for browsers, we should only have the origin browser do any redirect between 80 and 443.&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=200</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=200"/>
		<updated>2025-03-14T14:01:57Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Installation Scripts */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There will be a variety of Virtual Machines contained within the &#039;&#039;&#039;[[Home Lab]]&#039;&#039;&#039;. A Brief description will be provided here with a more complete set of notes on each individual VM on the links.&lt;br /&gt;
&lt;br /&gt;
==Virtual Machine Installation &amp;amp; Configuration Notes==&lt;br /&gt;
&lt;br /&gt;
===Qemu Agent Install===&lt;br /&gt;
&lt;br /&gt;
All VMs should have the qemu guest installed even server installs, it will allow the guest VM to communicate with Proxmox and give better options from the Proxmox . For Debian / Ubuntu type.&lt;br /&gt;
 sudo apt update &amp;amp;&amp;amp; install qemu-guest-agent&lt;br /&gt;
For Windows VMs there is a cd that can be referenced when defining the VM. On the OS page as soon as the Guest OS &amp;quot;Microsoft Windows&amp;quot; is selected a tick box, with the title &amp;quot;Add additional drive for VirtIO Drivers&amp;quot; appears. When selected find an ISO image &amp;quot;Virtio-win.iso&amp;quot;. If it is not available it can be added to the ISO library on Proxmox by downloading it from [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso] or [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso].&lt;br /&gt;
&lt;br /&gt;
==Virtual Machines==&lt;br /&gt;
A fairly high description of each of the VMs in use in the [[Home Lab]].&lt;br /&gt;
&lt;br /&gt;
===Firewall===&lt;br /&gt;
 &lt;br /&gt;
====[[Pfsense]]====&lt;br /&gt;
&lt;br /&gt;
The firewall and gateway to the whole of the [[Home Lab]]. The Virgin router will forward all incoming traffic from the Internet to the WAN port of the firewall at 192.168.0.125. The Firewall has five other internal interfaces to  link to the Home Lab environment. 192.168.99.10/24 is the MGT VLAN it should be severely restricted to maintain security it is the only VLAN to be able to access the WebGUI of Pfsense. The Production VLAN is where all of the file and web servers are, the gateway address is 192.168.100.1/24. The Infra VLAN gateway 192.168.110.10/24 is where any supporting services will be located, at present there is only a Nameserver. I have reserved a VLAN called VPNnet with a gateway address of 192.168.130.1/24 for a VPN server to provide a VPN tunnel from remote terminals, there will not be many concurrent connections so a /24 network will be more than sufficient. The last VLAN has a Pfsense interface of 192.168.111.1/24 for any Desktop VM terminals that I will use while i am out, I have called this terminals. Further details of the [[Pfsense]] firewall can be found [[Pfsense | here]].&lt;br /&gt;
&lt;br /&gt;
===MGT VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[Management kiosk]]====&lt;br /&gt;
&lt;br /&gt;
A desktop Linux used to configure other VMs including Pfsense. As it is so sensitive i have kept it isolated on the MGT VLAN. There I have setup passwordless ssh to various other VMs as well. The host is called Lemon and has an IP Address of MGT.20.&lt;br /&gt;
&lt;br /&gt;
====[[CA Server]]====&lt;br /&gt;
&lt;br /&gt;
I have setup a host specifically to issue SSL certificates. The host name is Alpine with an IP of 192.168.99.25/24. &lt;br /&gt;
&lt;br /&gt;
===Infra Vlan===&lt;br /&gt;
&lt;br /&gt;
====[[Nameserver]]====&lt;br /&gt;
&lt;br /&gt;
There is only one nameserver at the moment called ns1 Infra.11. It is the only host on the Infra VLAN.&lt;br /&gt;
&lt;br /&gt;
===VPNNet VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[VPNserver]]====&lt;br /&gt;
&lt;br /&gt;
There will be a VPN server called vanilla at VPNnet.5. It will control VPN access to the rest of the network.&lt;br /&gt;
&lt;br /&gt;
===Terminals===&lt;br /&gt;
&lt;br /&gt;
====[[Remote Access Terminal]]====&lt;br /&gt;
&lt;br /&gt;
There will be two VMs setup on teminals VLAN with a desktop that I will provide for remote access one of them will be Linux (Ubuntu), hostname Lychee and the other will be Windows 11 Pro with a hostname Wahoo.&lt;br /&gt;
&lt;br /&gt;
===Prodution===&lt;br /&gt;
&lt;br /&gt;
====[[Reverse Proxy]]====&lt;br /&gt;
&lt;br /&gt;
The Reverse proxy Ngnix install is hosted on Raisin production.9. It should be setup to fetch SSL certs from Letsencrypt and copy the certs to the various webservers that need them. It&#039;s primary role, of course is to manage access to the webservers.&lt;br /&gt;
&lt;br /&gt;
===[[Webservers]]===&lt;br /&gt;
&lt;br /&gt;
There wil be at least three webservers, One hosting www.seaoffate.net, another hosting plum.seaoffate.net and another hosting wiki.seaoffate.net. These will also be servicing .local addresses. MySQL will be on a different host. There will be other hosts that have some sort of webserver on them but not as a primary role.&lt;br /&gt;
&lt;br /&gt;
===[[File server]]===&lt;br /&gt;
&lt;br /&gt;
There is a file server called fig at Production.11. It will also have a webserver installed and will answer to files.seaoffate.net &amp;amp; files.seaoffate.local. It should be configured to serve files using NFS,FTP and SMB locally but only SFTP externally.&lt;br /&gt;
&lt;br /&gt;
===[[MySQL Server]]===&lt;br /&gt;
&lt;br /&gt;
Manderin at Production.8 is hosting the MySQL Databases.I will probably install phpmyadmin at some point to make DB management a bit easier but I doubt if I will give it external access.&lt;br /&gt;
&lt;br /&gt;
===[[UpLoad Server]]===&lt;br /&gt;
&lt;br /&gt;
There is an server especially set for SFTP and SMB serving. It will be on Production.25. It will have a large HD that will be used to import and export all pictures from the network.&lt;br /&gt;
&lt;br /&gt;
===[[Backup Server]]===&lt;br /&gt;
&lt;br /&gt;
We will have a dedicated backup server, Strawberry, that will share files with other servers like the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; server by NFS. It will mostly do not too much except monitor the files for others. If it looks like NFS is creating too much of a bottleneck we can look at storing photos directly on Plum and grabbing them periodically to upload. i will be doin just that so this note will change when i have reconfigured the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; and this server Strawberry.&lt;br /&gt;
&lt;br /&gt;
===Future VMs===&lt;br /&gt;
&lt;br /&gt;
I may well setup a streaming server with some sort of NFS RO share from the file server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Scripts==&lt;br /&gt;
&lt;br /&gt;
We are creating several scripts to speed up the installation of the VMs. some are long and major time savers and some are not much more than one or two lines.&lt;br /&gt;
&lt;br /&gt;
=====[[Webserver Setup]]=====&lt;br /&gt;
&lt;br /&gt;
Some Apache and Gninx scrips to speed up creation and deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
=====[[Add a Hostname &amp;amp; IP Address to DNSmsaq]]=====&lt;br /&gt;
&lt;br /&gt;
there is a script that can be run to add a dns record to dnsmasq currently frm the ~ off the user you should be able to do&lt;br /&gt;
 ./add_dns_record.sh &lt;br /&gt;
it will have two parameters one for hostname and the other for the IP Address of the host we would be dealing with.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Script to add or update a DNS record in dnsmasq&lt;br /&gt;
&lt;br /&gt;
# Get hostname and IP address from command line&lt;br /&gt;
HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
IP_ADDRESS=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Check if parameters are provided&lt;br /&gt;
if [ -z &amp;quot;$HOSTNAME&amp;quot; ] || [ -z &amp;quot;$IP_ADDRESS&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;Usage: sudo $0 &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
# Define filename&lt;br /&gt;
FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create DNS and PTR records&lt;br /&gt;
DNS_RECORD=&amp;quot;address=/$HOSTNAME.seaoffate.local/$IP_ADDRESS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Trim leading/trailing spaces from IP_ADDRESS&lt;br /&gt;
IP_ADDRESS=&amp;quot;${IP_ADDRESS#&amp;quot;${IP_ADDRESS%%[![:space:]]*}&amp;quot;}&amp;quot; # Remove leading spaces&lt;br /&gt;
IP_ADDRESS=&amp;quot;${IP_ADDRESS%&amp;quot;${IP_ADDRESS##*[![:space:]]}&amp;quot;}&amp;quot; # Remove trailing spaces&lt;br /&gt;
&lt;br /&gt;
# Reverse IP for PTR Record.&lt;br /&gt;
REVERSE_IP=$(echo &amp;quot;$IP_ADDRESS&amp;quot; | awk -F. &#039;{print $4&amp;quot;.&amp;quot;$3&amp;quot;.&amp;quot;$2&amp;quot;.&amp;quot;$1}&#039;)&lt;br /&gt;
&lt;br /&gt;
# Trim leading/trailing spaces from REVERSE_IP&lt;br /&gt;
REVERSE_IP=&amp;quot;${REVERSE_IP#&amp;quot;${REVERSE_IP%%[![:space:]]*}&amp;quot;}&amp;quot; # Remove leading spaces&lt;br /&gt;
REVERSE_IP=&amp;quot;${REVERSE_IP%&amp;quot;${REVERSE_IP##*[![:space:]]}&amp;quot;}&amp;quot; # Remove trailing spaces&lt;br /&gt;
&lt;br /&gt;
PTR_RECORD=&amp;quot;ptr-record=$REVERSE_IP.in-addr.arpa,$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Write records to file, overwriting any existing content&lt;br /&gt;
echo &amp;quot;$DNS_RECORD&amp;quot; | sudo tee &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
echo &amp;quot;$PTR_RECORD&amp;quot; | sudo tee -a &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Restart dnsmasq&lt;br /&gt;
sudo systemctl restart dnsmasq&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;DNS record added/updated for $HOSTNAME.seaoffate.local.&amp;quot;&lt;br /&gt;
echo &amp;quot;IP address: $IP_ADDRESS&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Set permissions on the file.&lt;br /&gt;
sudo chmod 644 &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Permissions set to 644 on $FILENAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# List the file with its permissions&lt;br /&gt;
echo &amp;quot;\nFile details:&amp;quot;&lt;br /&gt;
ls -l &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Restart dnsmasq again&lt;br /&gt;
sudo systemctl restart dnsmasq&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;dnsmasq restarted again to ensure changes are applied.&amp;quot;&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=199</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=199"/>
		<updated>2025-03-14T10:37:36Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Revove Website from Proxy (Raisin) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
====Install packages====&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
 #&lt;br /&gt;
 # Update package lists&lt;br /&gt;
 sudo apt update -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install Apache2&lt;br /&gt;
 sudo apt install apache2 -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install PHP and common extensions&lt;br /&gt;
 sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install MySQL client&lt;br /&gt;
 sudo apt install mysql-client -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install ImageMagick&lt;br /&gt;
 sudo apt install imagemagick -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install OpenSSH server (SFTP)&lt;br /&gt;
 sudo apt install openssh-server -y&lt;br /&gt;
 #&lt;br /&gt;
 # Enable SSH service&lt;br /&gt;
 sudo systemctl enable ssh&lt;br /&gt;
 #&lt;br /&gt;
 # Install exiftool (Exif reader)&lt;br /&gt;
 sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Apache2&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
====Website Config====&lt;br /&gt;
&lt;br /&gt;
Once Apache and it supporting packages are done we will need to create the config files. We will need 6 configs created.&lt;br /&gt;
* hostname.seaoffate.local as http&lt;br /&gt;
* hostname.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.local as http&lt;br /&gt;
* purpose.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.net as http&lt;br /&gt;
* purpose.seaoffate.net as https&lt;br /&gt;
The file will be stored in the Templates dir on nigel login on lemon Although there are six websites they all will serve from the same docroot. we will get one of the names from the hostname of the VM and the other will be the parameter in the call.&lt;br /&gt;
 ./apache_config.sh purpose&lt;br /&gt;
purpose will be what the reason for having the webserver eg wiki or photo. We do not need the .seaofffate.local or .net as that is assumed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Apache for HTTP and HTTPS, create directories, and enable modules &lt;br /&gt;
 #&lt;br /&gt;
 # Get website purpose from command line&lt;br /&gt;
 WEBSITE_PURPOSE=&amp;quot;$1&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if website purpose is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_PURPOSE&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo &amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;0 &amp;lt;website\_purpose\&amp;gt;&amp;quot;&lt;br /&gt;
 exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 \# Define hostname&lt;br /&gt;
 HOSTNAME\=&amp;lt;/span&amp;gt;(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_HOST=&amp;quot;$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_LOCAL=&amp;quot;$WEBSITE_PURPOSE.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_NET=&amp;quot;$WEBSITE_PURPOSE.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 DOC_ROOT=&amp;quot;/var/www/$WEBSITE_PURPOSE.seaoffate.local/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create document root directory&lt;br /&gt;
 sudo mkdir -p &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 sudo chown -R www-data:www-data &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories&lt;br /&gt;
 sudo mkdir -p /etc/apache2/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/apache2/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_HOST.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_HOST.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.key&amp;quot; | sudo tee -a /etc&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 # &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 # &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=198</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=198"/>
		<updated>2025-03-14T10:36:54Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Add site to Nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
====Install packages====&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
 #&lt;br /&gt;
 # Update package lists&lt;br /&gt;
 sudo apt update -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install Apache2&lt;br /&gt;
 sudo apt install apache2 -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install PHP and common extensions&lt;br /&gt;
 sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install MySQL client&lt;br /&gt;
 sudo apt install mysql-client -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install ImageMagick&lt;br /&gt;
 sudo apt install imagemagick -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install OpenSSH server (SFTP)&lt;br /&gt;
 sudo apt install openssh-server -y&lt;br /&gt;
 #&lt;br /&gt;
 # Enable SSH service&lt;br /&gt;
 sudo systemctl enable ssh&lt;br /&gt;
 #&lt;br /&gt;
 # Install exiftool (Exif reader)&lt;br /&gt;
 sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Apache2&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
====Website Config====&lt;br /&gt;
&lt;br /&gt;
Once Apache and it supporting packages are done we will need to create the config files. We will need 6 configs created.&lt;br /&gt;
* hostname.seaoffate.local as http&lt;br /&gt;
* hostname.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.local as http&lt;br /&gt;
* purpose.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.net as http&lt;br /&gt;
* purpose.seaoffate.net as https&lt;br /&gt;
The file will be stored in the Templates dir on nigel login on lemon Although there are six websites they all will serve from the same docroot. we will get one of the names from the hostname of the VM and the other will be the parameter in the call.&lt;br /&gt;
 ./apache_config.sh purpose&lt;br /&gt;
purpose will be what the reason for having the webserver eg wiki or photo. We do not need the .seaofffate.local or .net as that is assumed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Apache for HTTP and HTTPS, create directories, and enable modules &lt;br /&gt;
 #&lt;br /&gt;
 # Get website purpose from command line&lt;br /&gt;
 WEBSITE_PURPOSE=&amp;quot;$1&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if website purpose is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_PURPOSE&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo &amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;0 &amp;lt;website\_purpose\&amp;gt;&amp;quot;&lt;br /&gt;
 exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 \# Define hostname&lt;br /&gt;
 HOSTNAME\=&amp;lt;/span&amp;gt;(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_HOST=&amp;quot;$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_LOCAL=&amp;quot;$WEBSITE_PURPOSE.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_NET=&amp;quot;$WEBSITE_PURPOSE.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 DOC_ROOT=&amp;quot;/var/www/$WEBSITE_PURPOSE.seaoffate.local/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create document root directory&lt;br /&gt;
 sudo mkdir -p &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 sudo chown -R www-data:www-data &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories&lt;br /&gt;
 sudo mkdir -p /etc/apache2/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/apache2/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_HOST.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_HOST.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.key&amp;quot; | sudo tee -a /etc&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 # &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 #&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 # &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=197</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=197"/>
		<updated>2025-03-14T10:35:21Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Website Config */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
====Install packages====&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
 #&lt;br /&gt;
 # Update package lists&lt;br /&gt;
 sudo apt update -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install Apache2&lt;br /&gt;
 sudo apt install apache2 -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install PHP and common extensions&lt;br /&gt;
 sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install MySQL client&lt;br /&gt;
 sudo apt install mysql-client -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install ImageMagick&lt;br /&gt;
 sudo apt install imagemagick -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install OpenSSH server (SFTP)&lt;br /&gt;
 sudo apt install openssh-server -y&lt;br /&gt;
 #&lt;br /&gt;
 # Enable SSH service&lt;br /&gt;
 sudo systemctl enable ssh&lt;br /&gt;
 #&lt;br /&gt;
 # Install exiftool (Exif reader)&lt;br /&gt;
 sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Apache2&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
====Website Config====&lt;br /&gt;
&lt;br /&gt;
Once Apache and it supporting packages are done we will need to create the config files. We will need 6 configs created.&lt;br /&gt;
* hostname.seaoffate.local as http&lt;br /&gt;
* hostname.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.local as http&lt;br /&gt;
* purpose.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.net as http&lt;br /&gt;
* purpose.seaoffate.net as https&lt;br /&gt;
The file will be stored in the Templates dir on nigel login on lemon Although there are six websites they all will serve from the same docroot. we will get one of the names from the hostname of the VM and the other will be the parameter in the call.&lt;br /&gt;
 ./apache_config.sh purpose&lt;br /&gt;
purpose will be what the reason for having the webserver eg wiki or photo. We do not need the .seaofffate.local or .net as that is assumed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Apache for HTTP and HTTPS, create directories, and enable modules &lt;br /&gt;
 #&lt;br /&gt;
 # Get website purpose from command line&lt;br /&gt;
 WEBSITE_PURPOSE=&amp;quot;$1&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if website purpose is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_PURPOSE&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo &amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;0 &amp;lt;website\_purpose\&amp;gt;&amp;quot;&lt;br /&gt;
 exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 \# Define hostname&lt;br /&gt;
 HOSTNAME\=&amp;lt;/span&amp;gt;(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_HOST=&amp;quot;$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_LOCAL=&amp;quot;$WEBSITE_PURPOSE.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_NET=&amp;quot;$WEBSITE_PURPOSE.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 DOC_ROOT=&amp;quot;/var/www/$WEBSITE_PURPOSE.seaoffate.local/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create document root directory&lt;br /&gt;
 sudo mkdir -p &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 sudo chown -R www-data:www-data &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories&lt;br /&gt;
 sudo mkdir -p /etc/apache2/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/apache2/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_HOST.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_HOST.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.key&amp;quot; | sudo tee -a /etc&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=196</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=196"/>
		<updated>2025-03-14T10:34:57Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Apache Webservers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
====Install packages====&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
 #&lt;br /&gt;
 # Update package lists&lt;br /&gt;
 sudo apt update -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install Apache2&lt;br /&gt;
 sudo apt install apache2 -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install PHP and common extensions&lt;br /&gt;
 sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install MySQL client&lt;br /&gt;
 sudo apt install mysql-client -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install ImageMagick&lt;br /&gt;
 sudo apt install imagemagick -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install OpenSSH server (SFTP)&lt;br /&gt;
 sudo apt install openssh-server -y&lt;br /&gt;
 #&lt;br /&gt;
 # Enable SSH service&lt;br /&gt;
 sudo systemctl enable ssh&lt;br /&gt;
 #&lt;br /&gt;
 # Install exiftool (Exif reader)&lt;br /&gt;
 sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Apache2&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
====Website Config====&lt;br /&gt;
&lt;br /&gt;
Once Apache and it supporting packages are done we will need to create the config files. We will need 6 configs created.&lt;br /&gt;
* hostname.seaoffate.local as http&lt;br /&gt;
* hostname.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.local as http&lt;br /&gt;
* purpose.seaoffate.local as https&lt;br /&gt;
* purpose.seaoffate.net as http&lt;br /&gt;
* purpose.seaoffate.net as https&lt;br /&gt;
The file will be stored in the Templates dir on nigel login on lemon Although there are six websites they all will serve from the same docroot. we will get one of the names from the hostname of the VM and the other will be the parameter in the call.&lt;br /&gt;
 ./apache_config.sh purpose&lt;br /&gt;
purpose will be what the reason for having the webserver eg wiki or photo. We do not need the .seaofffate.local or .net as that is assumed&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to configure Apache for HTTP and HTTPS, create directories, and enable modules &lt;br /&gt;
 #&lt;br /&gt;
 # Get website purpose from command line&lt;br /&gt;
 WEBSITE_PURPOSE=&amp;quot;$1&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if website purpose is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_PURPOSE&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo &amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;0 &amp;lt;website\_purpose\&amp;gt;&amp;quot;&lt;br /&gt;
 exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 \# Define hostname&lt;br /&gt;
 HOSTNAME\=&amp;lt;/span&amp;gt;(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_HOST=&amp;quot;$HOSTNAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_LOCAL=&amp;quot;$WEBSITE_PURPOSE.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_PURPOSE_NET=&amp;quot;$WEBSITE_PURPOSE.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 DOC_ROOT=&amp;quot;/var/www/$WEBSITE_PURPOSE.seaoffate.local/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create document root directory&lt;br /&gt;
 sudo mkdir -p &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 sudo chown -R www-data:www-data &amp;quot;$DOC_ROOT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create SSL directories&lt;br /&gt;
 sudo mkdir -p /etc/apache2/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/apache2/ssl/&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for hostname.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_HOST&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_HOST\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_HOST-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_HOST.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_HOST.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_HOST-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.conf&lt;br /&gt;
&lt;br /&gt;
 # Create HTTPS configuration for purpose.local&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_LOCAL&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_LOCAL\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_LOCAL-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL.ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_LOCAL.key&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_LOCAL-ssl.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTP configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:80&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 echo &amp;quot;&amp;lt;/VirtualHost&amp;gt;&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET.conf&lt;br /&gt;
 #&lt;br /&gt;
 # Create HTTPS configuration for purpose.net&lt;br /&gt;
 echo &amp;quot;&amp;lt;VirtualHost *:443&amp;gt;&amp;quot; | sudo tee /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    ServerName $DOMAIN_PURPOSE_NET&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    DocumentRoot $DOC_ROOT&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    ErrorLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-error.log&amp;quot; | sudo tee -a /etc/apache2/sites-available/&amp;lt;span class=&amp;quot;math-inline&amp;quot;&amp;gt;DOMAIN\_PURPOSE\_NET\-ssl\.conf&lt;br /&gt;
 echo &amp;quot;    CustomLog \\&amp;lt;/span&amp;gt;{APACHE_LOG_DIR}/$DOMAIN_PURPOSE_NET-ssl-access.log combined&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLEngine on&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.crt&amp;quot; | sudo tee -a /etc/apache2/sites-available/$DOMAIN_PURPOSE_NET-ssl.conf&lt;br /&gt;
 echo &amp;quot;    SSLCertificateKeyFile /etc/apache2/ssl/$DOMAIN_PURPOSE_NET.key&amp;quot; | sudo tee -a /etc&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=195</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=195"/>
		<updated>2025-03-14T10:11:01Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Apache Webservers */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
 #&lt;br /&gt;
 # Update package lists&lt;br /&gt;
 sudo apt update -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install Apache2&lt;br /&gt;
 sudo apt install apache2 -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install PHP and common extensions&lt;br /&gt;
 sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install MySQL client&lt;br /&gt;
 sudo apt install mysql-client -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install ImageMagick&lt;br /&gt;
 sudo apt install imagemagick -y&lt;br /&gt;
 #&lt;br /&gt;
 # Install OpenSSH server (SFTP)&lt;br /&gt;
 sudo apt install openssh-server -y&lt;br /&gt;
 #&lt;br /&gt;
 # Enable SSH service&lt;br /&gt;
 sudo systemctl enable ssh&lt;br /&gt;
 #&lt;br /&gt;
 # Install exiftool (Exif reader)&lt;br /&gt;
 sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
 #&lt;br /&gt;
 # Restart Apache2&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 #&lt;br /&gt;
 echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=194</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=194"/>
		<updated>2025-03-14T10:08:31Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
==Apache Webservers==&lt;br /&gt;
&lt;br /&gt;
To help with installing the various packages for webservers we have a simple script to call apt to install them all. We have a copy in my Templates dir on lemon as we will need to copy it to the new webserver. After it is copied to the target webserver we call the script with&lt;br /&gt;
 ./lamp_client_install.sh &lt;br /&gt;
Although it is called lamp it only installs the MySQL client not the server(we will user the MySQL server on Mandarin) This what it does&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Script to install a LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader&lt;br /&gt;
&lt;br /&gt;
# Update package lists&lt;br /&gt;
sudo apt update -y&lt;br /&gt;
&lt;br /&gt;
# Install Apache2&lt;br /&gt;
sudo apt install apache2 -y&lt;br /&gt;
&lt;br /&gt;
# Install PHP and common extensions&lt;br /&gt;
sudo apt install php libapache2-mod-php php-cli php-mysql php-gd php-curl php-xml php-mbstring php-zip -y&lt;br /&gt;
&lt;br /&gt;
# Install MySQL client&lt;br /&gt;
sudo apt install mysql-client -y&lt;br /&gt;
&lt;br /&gt;
# Install ImageMagick&lt;br /&gt;
sudo apt install imagemagick -y&lt;br /&gt;
&lt;br /&gt;
# Install OpenSSH server (SFTP)&lt;br /&gt;
sudo apt install openssh-server -y&lt;br /&gt;
&lt;br /&gt;
# Enable SSH service&lt;br /&gt;
sudo systemctl enable ssh&lt;br /&gt;
&lt;br /&gt;
# Install exiftool (Exif reader)&lt;br /&gt;
sudo apt install libimage-exiftool-perl -y&lt;br /&gt;
&lt;br /&gt;
# Restart Apache2&lt;br /&gt;
sudo systemctl restart apache2&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;LAMP server (MySQL client only), PHP, ImageMagick, SFTP, and Exif reader installation complete.&amp;quot;&lt;br /&gt;
echo &amp;quot;Apache2 is running. SSH is enabled.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=193</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=193"/>
		<updated>2025-03-14T09:56:13Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Add site to Nginx==&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=192</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=192"/>
		<updated>2025-03-14T09:54:47Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Add site to Nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Add site to Nginx====&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address&lt;br /&gt;
 website_fwd_config.sh websitename x.x.x.x&lt;br /&gt;
There is no need to add seaoffate.local or .net. this script will create four configs. &lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. &#039;&#039;&#039;Note we will have to do this for a hostname and the purpose&#039;&#039;&#039; as the hostname will not be known here eg run once for photo and once more for plum.&lt;br /&gt;
&lt;br /&gt;
If it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=191</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=191"/>
		<updated>2025-03-14T09:47:48Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Add site to Nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Add site to Nginx====&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address there is no need to add seaoffate.local or .net. this script will create four configs.&lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. if it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
====Revove Website from Proxy (Raisin)====&lt;br /&gt;
&lt;br /&gt;
We all make mistakes and we have to recover. This script will remove mistakes created by the website_fwd_config.sh above call it with&lt;br /&gt;
 ./remove_nginx_website.sh sitename&lt;br /&gt;
sitename is the site that needs to be removed, only the host potion needs to be supplied do not put in the .seaoffate.let or .seaoffate.local because it will remove all four configs(.local &amp;amp; .net and http ang https). All four website configs created above will be removed from /etc/nginx/sites-available &amp;amp; sites.enabled.&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to remove an Nginx reverse proxy website configuration&lt;br /&gt;
&lt;br /&gt;
 # Get website name from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if website name is provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Define configuration file paths&lt;br /&gt;
 CONFIG_LOCAL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 CONFIG_LOCAL_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&amp;quot;&lt;br /&gt;
 CONFIG_NET=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET&amp;quot;&lt;br /&gt;
 CONFIG_NET_SSL=&amp;quot;/etc/nginx/sites-available/$DOMAIN_NET-ssl&amp;quot;&lt;br /&gt;
 SYMLINK_LOCAL=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_LOCAL&amp;quot;&lt;br /&gt;
 SYMLINK_NET=&amp;quot;/etc/nginx/sites-enabled/$DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove configuration files&lt;br /&gt;
 sudo rm -f &amp;quot;$CONFIG_LOCAL&amp;quot; &amp;quot;$CONFIG_LOCAL_SSL&amp;quot; &amp;quot;$CONFIG_NET&amp;quot; &amp;quot;$CONFIG_NET_SSL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Remove symbolic links (disable sites)&lt;br /&gt;
 sudo rm -f &amp;quot;$SYMLINK_LOCAL&amp;quot; &amp;quot;$SYMLINK_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;Nginx website configuration removed.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Website: $WEBSITE_NAME&amp;quot;&lt;br /&gt;
 echo &amp;quot;Domains: $DOMAIN_LOCAL and $DOMAIN_NET&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # List sites-available directory&lt;br /&gt;
 echo &amp;quot;\nContents of /etc/nginx/sites-available/: &amp;quot;&lt;br /&gt;
 ls -l /etc/nginx/sites-available/&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=190</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=190"/>
		<updated>2025-03-14T09:33:27Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: Created page with &amp;quot;==Introduction==  Some scripts to help with the deployment of webservers.   ====Add site to Nginx====  This will take two parameters the first is the website name and the second is the IP address there is no need to add seaoffate.local or .net. this script will create four configs. * sitename.seaoffate.local as http * sitename.seaoffate.local as https * sitename.seaoffate.net as http * sitename.seaoffate.net as https It should enable both of the http: versions (.local &amp;amp;...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Some scripts to help with the deployment of webservers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Add site to Nginx====&lt;br /&gt;
&lt;br /&gt;
This will take two parameters the first is the website name and the second is the IP address there is no need to add seaoffate.local or .net. this script will create four configs.&lt;br /&gt;
* sitename.seaoffate.local as http&lt;br /&gt;
* sitename.seaoffate.local as https&lt;br /&gt;
* sitename.seaoffate.net as http&lt;br /&gt;
* sitename.seaoffate.net as https&lt;br /&gt;
It should enable both of the http: versions (.local &amp;amp; .net) but it will not enable the https: so we have some time to get the certs done before ssl is deployed. note that the .local is sharing the same certificate amongst all of the .local websites that are  being deployed here. The script is on Raisin on the root of nigel. if it is lost it can be deployed again from this:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to configure Nginx as a reverse proxy&lt;br /&gt;
&lt;br /&gt;
 # Get website name, IP address from command line&lt;br /&gt;
 WEBSITE_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FORWARD_IP=&amp;quot;$2&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Check if parameters are provided&lt;br /&gt;
 if [ -z &amp;quot;$WEBSITE_NAME&amp;quot; ] || [ -z &amp;quot;$FORWARD_IP&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: sudo $0 &amp;lt;website_name&amp;gt; &amp;lt;forward_ip&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
 # Define domain names&lt;br /&gt;
 DOMAIN_LOCAL=&amp;quot;$WEBSITE_NAME.seaoffate.local&amp;quot;&lt;br /&gt;
 DOMAIN_NET=&amp;quot;$WEBSITE_NAME.seaoffate.net&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # Create Nginx configuration file for .local&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .local (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_LOCAL;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/ssl/certs/raisin.seaoffate.local.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/ssl/private/raisin.seaoffate.local.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_LOCAL-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    listen 80;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET&lt;br /&gt;
&lt;br /&gt;
 # Create Nginx configuration file for .net (HTTPS, but not enabled)&lt;br /&gt;
 echo &amp;quot;server {&amp;quot; | sudo tee /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    listen 443 ssl;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    server_name $DOMAIN_NET;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate /etc/nginx/ssl/$DOMAIN_NET.crt;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    ssl_certificate_key /etc/nginx/ssl/$DOMAIN_NET.key;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    location / {&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_pass http://$FORWARD_IP/;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header Host \$host;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Real-IP \$remote_addr;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;        proxy_set_header X-Forwarded-Proto \$scheme;&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;    }&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
 echo &amp;quot;}&amp;quot; | sudo tee -a /etc/nginx/sites-available/$DOMAIN_NET-ssl&lt;br /&gt;
&lt;br /&gt;
 # Create SSL directories (only for .net)&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl/&lt;br /&gt;
 sudo chmod 700 /etc/nginx/ssl/&lt;br /&gt;
&lt;br /&gt;
 # Enable HTTP sites&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_LOCAL /etc/nginx/sites-enabled/&lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/$DOMAIN_NET /etc/nginx/sites-enabled/&lt;br /&gt;
&lt;br /&gt;
 # Restart Nginx&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 &lt;br /&gt;
 echo &amp;quot;Nginx configuration complete.&amp;quot;&lt;br /&gt;
 echo &amp;quot;HTTP sites enabled. SSL directories created.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Add your Cloudflare SSL certificates to /etc/nginx/ssl/ for .net and enable HTTPS sites.&amp;quot;&lt;br /&gt;
 echo &amp;quot;Using existing certs for .seaoffate.local.&amp;quot;&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=189</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=189"/>
		<updated>2025-03-14T09:12:37Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Webserver Setup= */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There will be a variety of Virtual Machines contained within the &#039;&#039;&#039;[[Home Lab]]&#039;&#039;&#039;. A Brief description will be provided here with a more complete set of notes on each individual VM on the links.&lt;br /&gt;
&lt;br /&gt;
==Virtual Machine Installation &amp;amp; Configuration Notes==&lt;br /&gt;
&lt;br /&gt;
===Qemu Agent Install===&lt;br /&gt;
&lt;br /&gt;
All VMs should have the qemu guest installed even server installs, it will allow the guest VM to communicate with Proxmox and give better options from the Proxmox . For Debian / Ubuntu type.&lt;br /&gt;
 sudo apt update &amp;amp;&amp;amp; install qemu-guest-agent&lt;br /&gt;
For Windows VMs there is a cd that can be referenced when defining the VM. On the OS page as soon as the Guest OS &amp;quot;Microsoft Windows&amp;quot; is selected a tick box, with the title &amp;quot;Add additional drive for VirtIO Drivers&amp;quot; appears. When selected find an ISO image &amp;quot;Virtio-win.iso&amp;quot;. If it is not available it can be added to the ISO library on Proxmox by downloading it from [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso] or [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso].&lt;br /&gt;
&lt;br /&gt;
==Virtual Machines==&lt;br /&gt;
A fairly high description of each of the VMs in use in the [[Home Lab]].&lt;br /&gt;
&lt;br /&gt;
===Firewall===&lt;br /&gt;
 &lt;br /&gt;
====[[Pfsense]]====&lt;br /&gt;
&lt;br /&gt;
The firewall and gateway to the whole of the [[Home Lab]]. The Virgin router will forward all incoming traffic from the Internet to the WAN port of the firewall at 192.168.0.125. The Firewall has five other internal interfaces to  link to the Home Lab environment. 192.168.99.10/24 is the MGT VLAN it should be severely restricted to maintain security it is the only VLAN to be able to access the WebGUI of Pfsense. The Production VLAN is where all of the file and web servers are, the gateway address is 192.168.100.1/24. The Infra VLAN gateway 192.168.110.10/24 is where any supporting services will be located, at present there is only a Nameserver. I have reserved a VLAN called VPNnet with a gateway address of 192.168.130.1/24 for a VPN server to provide a VPN tunnel from remote terminals, there will not be many concurrent connections so a /24 network will be more than sufficient. The last VLAN has a Pfsense interface of 192.168.111.1/24 for any Desktop VM terminals that I will use while i am out, I have called this terminals. Further details of the [[Pfsense]] firewall can be found [[Pfsense | here]].&lt;br /&gt;
&lt;br /&gt;
===MGT VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[Management kiosk]]====&lt;br /&gt;
&lt;br /&gt;
A desktop Linux used to configure other VMs including Pfsense. As it is so sensitive i have kept it isolated on the MGT VLAN. There I have setup passwordless ssh to various other VMs as well. The host is called Lemon and has an IP Address of MGT.20.&lt;br /&gt;
&lt;br /&gt;
====[[CA Server]]====&lt;br /&gt;
&lt;br /&gt;
I have setup a host specifically to issue SSL certificates. The host name is Alpine with an IP of 192.168.99.25/24. &lt;br /&gt;
&lt;br /&gt;
===Infra Vlan===&lt;br /&gt;
&lt;br /&gt;
====[[Nameserver]]====&lt;br /&gt;
&lt;br /&gt;
There is only one nameserver at the moment called ns1 Infra.11. It is the only host on the Infra VLAN.&lt;br /&gt;
&lt;br /&gt;
===VPNNet VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[VPNserver]]====&lt;br /&gt;
&lt;br /&gt;
There will be a VPN server called vanilla at VPNnet.5. It will control VPN access to the rest of the network.&lt;br /&gt;
&lt;br /&gt;
===Terminals===&lt;br /&gt;
&lt;br /&gt;
====[[Remote Access Terminal]]====&lt;br /&gt;
&lt;br /&gt;
There will be two VMs setup on teminals VLAN with a desktop that I will provide for remote access one of them will be Linux (Ubuntu), hostname Lychee and the other will be Windows 11 Pro with a hostname Wahoo.&lt;br /&gt;
&lt;br /&gt;
===Prodution===&lt;br /&gt;
&lt;br /&gt;
====[[Reverse Proxy]]====&lt;br /&gt;
&lt;br /&gt;
The Reverse proxy Ngnix install is hosted on Raisin production.9. It should be setup to fetch SSL certs from Letsencrypt and copy the certs to the various webservers that need them. It&#039;s primary role, of course is to manage access to the webservers.&lt;br /&gt;
&lt;br /&gt;
===[[Webservers]]===&lt;br /&gt;
&lt;br /&gt;
There wil be at least three webservers, One hosting www.seaoffate.net, another hosting plum.seaoffate.net and another hosting wiki.seaoffate.net. These will also be servicing .local addresses. MySQL will be on a different host. There will be other hosts that have some sort of webserver on them but not as a primary role.&lt;br /&gt;
&lt;br /&gt;
===[[File server]]===&lt;br /&gt;
&lt;br /&gt;
There is a file server called fig at Production.11. It will also have a webserver installed and will answer to files.seaoffate.net &amp;amp; files.seaoffate.local. It should be configured to serve files using NFS,FTP and SMB locally but only SFTP externally.&lt;br /&gt;
&lt;br /&gt;
===[[MySQL Server]]===&lt;br /&gt;
&lt;br /&gt;
Manderin at Production.8 is hosting the MySQL Databases.I will probably install phpmyadmin at some point to make DB management a bit easier but I doubt if I will give it external access.&lt;br /&gt;
&lt;br /&gt;
===[[UpLoad Server]]===&lt;br /&gt;
&lt;br /&gt;
There is an server especially set for SFTP and SMB serving. It will be on Production.25. It will have a large HD that will be used to import and export all pictures from the network.&lt;br /&gt;
&lt;br /&gt;
===[[Backup Server]]===&lt;br /&gt;
&lt;br /&gt;
We will have a dedicated backup server, Strawberry, that will share files with other servers like the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; server by NFS. It will mostly do not too much except monitor the files for others. If it looks like NFS is creating too much of a bottleneck we can look at storing photos directly on Plum and grabbing them periodically to upload. i will be doin just that so this note will change when i have reconfigured the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; and this server Strawberry.&lt;br /&gt;
&lt;br /&gt;
===Future VMs===&lt;br /&gt;
&lt;br /&gt;
I may well setup a streaming server with some sort of NFS RO share from the file server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Scripts==&lt;br /&gt;
&lt;br /&gt;
We are creating several scripts to speed up the installation of the VMs. some are long and major time savers and some are not much more than one or two lines.&lt;br /&gt;
&lt;br /&gt;
=====[[Webserver Setup]]=====&lt;br /&gt;
&lt;br /&gt;
Some Apache and Gninx scrips to speed up creation and depllyment of webservers.&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=188</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=188"/>
		<updated>2025-03-14T09:12:10Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Future VMs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There will be a variety of Virtual Machines contained within the &#039;&#039;&#039;[[Home Lab]]&#039;&#039;&#039;. A Brief description will be provided here with a more complete set of notes on each individual VM on the links.&lt;br /&gt;
&lt;br /&gt;
==Virtual Machine Installation &amp;amp; Configuration Notes==&lt;br /&gt;
&lt;br /&gt;
===Qemu Agent Install===&lt;br /&gt;
&lt;br /&gt;
All VMs should have the qemu guest installed even server installs, it will allow the guest VM to communicate with Proxmox and give better options from the Proxmox . For Debian / Ubuntu type.&lt;br /&gt;
 sudo apt update &amp;amp;&amp;amp; install qemu-guest-agent&lt;br /&gt;
For Windows VMs there is a cd that can be referenced when defining the VM. On the OS page as soon as the Guest OS &amp;quot;Microsoft Windows&amp;quot; is selected a tick box, with the title &amp;quot;Add additional drive for VirtIO Drivers&amp;quot; appears. When selected find an ISO image &amp;quot;Virtio-win.iso&amp;quot;. If it is not available it can be added to the ISO library on Proxmox by downloading it from [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso] or [https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso].&lt;br /&gt;
&lt;br /&gt;
==Virtual Machines==&lt;br /&gt;
A fairly high description of each of the VMs in use in the [[Home Lab]].&lt;br /&gt;
&lt;br /&gt;
===Firewall===&lt;br /&gt;
 &lt;br /&gt;
====[[Pfsense]]====&lt;br /&gt;
&lt;br /&gt;
The firewall and gateway to the whole of the [[Home Lab]]. The Virgin router will forward all incoming traffic from the Internet to the WAN port of the firewall at 192.168.0.125. The Firewall has five other internal interfaces to  link to the Home Lab environment. 192.168.99.10/24 is the MGT VLAN it should be severely restricted to maintain security it is the only VLAN to be able to access the WebGUI of Pfsense. The Production VLAN is where all of the file and web servers are, the gateway address is 192.168.100.1/24. The Infra VLAN gateway 192.168.110.10/24 is where any supporting services will be located, at present there is only a Nameserver. I have reserved a VLAN called VPNnet with a gateway address of 192.168.130.1/24 for a VPN server to provide a VPN tunnel from remote terminals, there will not be many concurrent connections so a /24 network will be more than sufficient. The last VLAN has a Pfsense interface of 192.168.111.1/24 for any Desktop VM terminals that I will use while i am out, I have called this terminals. Further details of the [[Pfsense]] firewall can be found [[Pfsense | here]].&lt;br /&gt;
&lt;br /&gt;
===MGT VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[Management kiosk]]====&lt;br /&gt;
&lt;br /&gt;
A desktop Linux used to configure other VMs including Pfsense. As it is so sensitive i have kept it isolated on the MGT VLAN. There I have setup passwordless ssh to various other VMs as well. The host is called Lemon and has an IP Address of MGT.20.&lt;br /&gt;
&lt;br /&gt;
====[[CA Server]]====&lt;br /&gt;
&lt;br /&gt;
I have setup a host specifically to issue SSL certificates. The host name is Alpine with an IP of 192.168.99.25/24. &lt;br /&gt;
&lt;br /&gt;
===Infra Vlan===&lt;br /&gt;
&lt;br /&gt;
====[[Nameserver]]====&lt;br /&gt;
&lt;br /&gt;
There is only one nameserver at the moment called ns1 Infra.11. It is the only host on the Infra VLAN.&lt;br /&gt;
&lt;br /&gt;
===VPNNet VLAN===&lt;br /&gt;
&lt;br /&gt;
====[[VPNserver]]====&lt;br /&gt;
&lt;br /&gt;
There will be a VPN server called vanilla at VPNnet.5. It will control VPN access to the rest of the network.&lt;br /&gt;
&lt;br /&gt;
===Terminals===&lt;br /&gt;
&lt;br /&gt;
====[[Remote Access Terminal]]====&lt;br /&gt;
&lt;br /&gt;
There will be two VMs setup on teminals VLAN with a desktop that I will provide for remote access one of them will be Linux (Ubuntu), hostname Lychee and the other will be Windows 11 Pro with a hostname Wahoo.&lt;br /&gt;
&lt;br /&gt;
===Prodution===&lt;br /&gt;
&lt;br /&gt;
====[[Reverse Proxy]]====&lt;br /&gt;
&lt;br /&gt;
The Reverse proxy Ngnix install is hosted on Raisin production.9. It should be setup to fetch SSL certs from Letsencrypt and copy the certs to the various webservers that need them. It&#039;s primary role, of course is to manage access to the webservers.&lt;br /&gt;
&lt;br /&gt;
===[[Webservers]]===&lt;br /&gt;
&lt;br /&gt;
There wil be at least three webservers, One hosting www.seaoffate.net, another hosting plum.seaoffate.net and another hosting wiki.seaoffate.net. These will also be servicing .local addresses. MySQL will be on a different host. There will be other hosts that have some sort of webserver on them but not as a primary role.&lt;br /&gt;
&lt;br /&gt;
===[[File server]]===&lt;br /&gt;
&lt;br /&gt;
There is a file server called fig at Production.11. It will also have a webserver installed and will answer to files.seaoffate.net &amp;amp; files.seaoffate.local. It should be configured to serve files using NFS,FTP and SMB locally but only SFTP externally.&lt;br /&gt;
&lt;br /&gt;
===[[MySQL Server]]===&lt;br /&gt;
&lt;br /&gt;
Manderin at Production.8 is hosting the MySQL Databases.I will probably install phpmyadmin at some point to make DB management a bit easier but I doubt if I will give it external access.&lt;br /&gt;
&lt;br /&gt;
===[[UpLoad Server]]===&lt;br /&gt;
&lt;br /&gt;
There is an server especially set for SFTP and SMB serving. It will be on Production.25. It will have a large HD that will be used to import and export all pictures from the network.&lt;br /&gt;
&lt;br /&gt;
===[[Backup Server]]===&lt;br /&gt;
&lt;br /&gt;
We will have a dedicated backup server, Strawberry, that will share files with other servers like the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; server by NFS. It will mostly do not too much except monitor the files for others. If it looks like NFS is creating too much of a bottleneck we can look at storing photos directly on Plum and grabbing them periodically to upload. i will be doin just that so this note will change when i have reconfigured the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; and this server Strawberry.&lt;br /&gt;
&lt;br /&gt;
===Future VMs===&lt;br /&gt;
&lt;br /&gt;
I may well setup a streaming server with some sort of NFS RO share from the file server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Installation Scripts==&lt;br /&gt;
&lt;br /&gt;
We are creating several scripts to speed up the installation of the VMs. some are long and major time savers and some are not much more than one or two lines.&lt;br /&gt;
&lt;br /&gt;
=====[[Webserver Setup]]======&lt;br /&gt;
&lt;br /&gt;
Some Apache and Gninx scrips to speed up creation and depllyment of webservers.&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=143</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=143"/>
		<updated>2025-03-13T05:31:57Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Raisin Nginx Reverse Proxy Configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There will be several Webservers in the &#039;&#039;&#039;[[Home Lab]]&#039;&#039;&#039;. Each will be on it&#039;s own &#039;&#039;&#039;[[Virtual Machines]]&#039;&#039;&#039; and will be on the production VLAN. The MySQL databases will be on a separate VM on the same network so no connectivity problems from that. The Proxy server will forward all web traffic to the appropriate webserver.&lt;br /&gt;
&lt;br /&gt;
==SSL Config==&lt;br /&gt;
&lt;br /&gt;
There will be two setups for SSL/TLS one for the seaoffate.local and one for seaoffate.net.&lt;br /&gt;
&lt;br /&gt;
===Local DNS Names SSL Setup===&lt;br /&gt;
&lt;br /&gt;
We will do the SSL/TLS for the .local access first mainly because because it is better to see it working on a local level and if we did the global first there is a good chance we would never get a around to doing the local, in which case some of the access will be completely without any cert. It is part of the learning curve to generate SSL certificates. While it would be fairly easier to do a self cert for the local access it is better to experience the whole process from start to finish to get a complete understanding of how it is done and the failures that inevitably appear. &lt;br /&gt;
&lt;br /&gt;
==== The Process Flow====&lt;br /&gt;
&lt;br /&gt;
The process flow is to get the Certificates generated on the webserver host, get it signed by the Certificate Authority then apply it to the webserver, once that is done the SSL config needs to be applied to the host, after that it we would make a config to the reverse proxy. The reverse proxy will have it&#039;s own certificate to use for all of the hosts that it is forwarding to and once the cert is applied it will not need to have it applied again, we would just refer to it in the individual SSL config.  &lt;br /&gt;
&lt;br /&gt;
====Generating SSL Certificates====&lt;br /&gt;
&lt;br /&gt;
The first thing to do is to generate a private key, this is done on the webserver with the command&lt;br /&gt;
 sudo openssl genrsa -out /etc/ssl/private/strawberry.seaoffate.local.key 2048&lt;br /&gt;
The out directive will specify where the private key will stored, in this case the default location is used. The .key does need to be stored  privately as it is the key that will be used to encrypt or decrypt the internet traffic and is the core item in the security of the Internet. Once the private key has been generated access should be restricted to the root user only so we need to do the chmod/chown commanda s follows&lt;br /&gt;
 sudo chmod 600 /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
 sudo chown root:root /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
Now that we have the private key we can look at getting the public certificate. To get the certificate with any sort of trust it has to be signed by a Certificate Authority. We have a personal CA available on Alpine, it will only be trusted by us and not the rest of the world as it is a personal CA. To have a cert signed we must generate a Certificate Signing Request and present it to the CA the command to generate a CSR is &lt;br /&gt;
 sudo openssl req -new -key /etc/ssl/private/strawberry.seaoffate.local.key -out /etc/ssl/certs/strawberry.seaoffate.local.csr&lt;br /&gt;
As this script executes it will ask a numer of questions.&lt;br /&gt;
* Country Name (2 letter code) [AU]:GB&lt;br /&gt;
* State or Province Name (full name) [Some-State]:Hampshire&lt;br /&gt;
* Locality Name (eg, city) []:Basingstoke&lt;br /&gt;
* Organization Name (eg, company) [Internet Widgits Pty Ltd]:Sea of Fate&lt;br /&gt;
* Organizational Unit Name (eg, section) []: (Your department or unit, if applicable, or leave blank)&lt;br /&gt;
* Common Name (e.g. server FQDN or YOUR name) []: strawberry.seaoffate.local (This is crucial, it must match the hostname)&lt;br /&gt;
* Email Address []:sailor@seaoffate.net&lt;br /&gt;
* A challenge password []: (Leave blank, or add a password, but it is not needed for webserver certificates)&lt;br /&gt;
* An optional company name []: (Leave blank, or add an optional company name)&lt;br /&gt;
&#039;&#039;&#039;Note that the Common Name is critical&#039;&#039;&#039; The other fields are not so important but should be accurate (don&#039;t lie someone may read them), the fields could be left blank (except common name). the challenge password is rarely used for webserver certs and can be left blank.&lt;br /&gt;
&lt;br /&gt;
Note that the command uses the  private key that we just generated. The CSR is added to the certs directory it is not secret but it should not be modified so it still need to be stored in a form that has at least 744 on it. As this is a signing request we have to get is to the signing software, the CA, in a secure manner. generally SCP is the best option to transfer a file securely as it uses the same connection as SSH. An example is  &lt;br /&gt;
 scp /etc/ssl/certs/strawberry.seaoffate.local.csr user@alpine:~/easy-rsa/easyrsa3/pki/reqs/&lt;br /&gt;
If this doesn&#039;t work with the user that is available try copying to /tmp&lt;br /&gt;
 scp /etc/ssl/certs/strawberry.seaoffate.local.csr user@alpine:/tmp&lt;br /&gt;
When the file is copied to Apline we must login to the Alpine host to do the signing. I the CSR file could not be added directly to the reqs directory it should be copied there now. &lt;br /&gt;
 cp /tmp/strawberry.seaoffate.local.csr ~/easy-rsa/easyrsa3/pki/reqs&lt;br /&gt;
Unfortunately, easyrsa need to see CSRs with the extension of .req but the openssl generates them as .csr the solution is to mv the .csr to .req &lt;br /&gt;
 mv ~/easy-rsa/easyrsa3/pki/reqs/strawberry.seaoffate.local.csr ~/easy-rsa/easyrsa3/pki/reqs/strawberry.seaoffate.local.req&lt;br /&gt;
Assuming that the CSR is in the /reqs directory and it has the correct extension we can proceed with the signing. We should be in the ~/easy-rsa/easyrsa3/ directory to run the script&lt;br /&gt;
 ./easyrsa sign-req server strawberry.seaoffate.local&lt;br /&gt;
the script will ask to confirm the details that would have been submitted when creating the signing request on the web host and the first answer has to be &amp;quot;yes&amp;quot; or it will not continue. The next question is to supply the passphrase for the script to have access to the CA.key, if it can&#039;t be given the request fails. Once the CSR/REQ has been signed the certificate will be created and stored in the issued directory and is ready to be returned to the webserver again using SCP. We could copy the .CRT directly to the /ect/ssl/certs dir on the web host but since we are using Ubuntu we can&#039;t because the permissions fail. We should create a dir off of the user&#039;s home dir and call it signed we can then SCP &lt;br /&gt;
 SCP ~/easy-rsa/easyrsa3/pki/issued/strawberry.seaoffate.local.crt user@strawberry.seaoffate.local:~/signed&lt;br /&gt;
When that is done swap back to the web host (strawberry) and mv the signed cert to the correct directory&lt;br /&gt;
 sudo mv signed/strawberry.seaoffate.local.crt /etc/ssl/certs/&lt;br /&gt;
We should set the permissions on the cert to be read only and owned by root&lt;br /&gt;
 sudo chmod 644 /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
 sudo chown root:root /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
As a final job we can verify that the cert and key match each other&lt;br /&gt;
 sudo openssl x509 -noout -modulus -in /etc/ssl/certs/strawberry.seaoffate.local.crt | sudo openssl sha256&lt;br /&gt;
 sudo openssl rsa -noout -modulus -in /etc/ssl/private/strawberry.seaoffate.local.key | sudo openssl sha256&lt;br /&gt;
check to make sure that the two hashes are identical, if they are not SSL will not work on the website.&lt;br /&gt;
&lt;br /&gt;
====Create Apache SSL Configuration====&lt;br /&gt;
&lt;br /&gt;
Now that we have a signed certificate we can proceed to configure Apache to listen &amp;amp; serve SSL/TLS request on port 443. As we have used Strawberry as the example for the cert generation we will continue to use the same host for the configs. First we should cd to the site-available so that the config file we create matches the existing and we get the correct docroot. We should create a config file,&lt;br /&gt;
 sudo nano /etc/apache2/sites-available/strawberry.seaoffate.local-ssl.conf&lt;br /&gt;
and enter the following&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName strawberry.seaoffate.local&lt;br /&gt;
    DocumentRoot /var/www/strawberry/public_html&lt;br /&gt;
&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;Directory /var/www/strawberry/public_html/&amp;gt;&lt;br /&gt;
        AllowOverride All&lt;br /&gt;
        Require all granted&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # Security Headers (Recommended)&lt;br /&gt;
    Header always set Strict-Transport-Security &amp;quot;max-age=63072000; includeSubDomains; preload&amp;quot;&lt;br /&gt;
    Header always set X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
    Header always set X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
    Header always set Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # SSL Protocol and Cipher Configuration (Recommended)&lt;br /&gt;
    SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
    SSLCipherSuite HIGH:!aNULL:!MD5&lt;br /&gt;
&lt;br /&gt;
    ErrorLog ${APACHE_LOG_DIR}/error.log&lt;br /&gt;
    CustomLog ${APACHE_LOG_DIR}/access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit. To enable the SSL site and enable the SSL modules.&lt;br /&gt;
  sudo a2ensite strawberry.seaoffate.local-ssl.conf&lt;br /&gt;
 sudo a2enmod ssl&lt;br /&gt;
 sudo a2enmod headers&lt;br /&gt;
To restart Apache &amp;amp; check for errors&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 sudo systemctl status apache2&lt;br /&gt;
To test with curl &lt;br /&gt;
 curl -v https://strawberry.seaoffate.local&lt;br /&gt;
We should also look in a browser to be sure that the config works.&lt;br /&gt;
&lt;br /&gt;
==== Raisin Nginx Reverse Proxy Configuration====&lt;br /&gt;
&lt;br /&gt;
Once we have tested the webserver SSL config we should do the same for Raisin, the Reverse Proxy, First of all ssh to raisin and cd to /etc/nginx/sites-available to check what the format is for the existing configs. Create anew config for strawberry&lt;br /&gt;
 sudo nano strawberry.seaoffate.local.ssl.conf&lt;br /&gt;
fill in the following configuration&lt;br /&gt;
 server {&lt;br /&gt;
    listen 443 ssl;&lt;br /&gt;
    server_name strawberry.seaoffate.local;&lt;br /&gt;
&lt;br /&gt;
    ssl_certificate /etc/nginx/ssl/raisin.crt; # Path to your SSL certificate on raisin&lt;br /&gt;
    ssl_certificate_key /etc/nginx/ssl/raisin.key; # Path to your SSL key on raisin&lt;br /&gt;
&lt;br /&gt;
    ssl_protocols TLSv1.2 TLSv1.3;&lt;br /&gt;
    ssl_ciphers &#039;HIGH:!aNULL:!MD5&#039;; # !aNULL: This excludes ciphers that use anonymous Diffie-Hellman key exchange !MD5&#039; excludes weak md5 hash &lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass https://*.*.*.23; # IP of strawberry&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
        proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
        proxy_ssl_verify off; # only needed if strawberry has a self signed cert.&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
Save and exit. If this is the first SSL website to be proxy, we will need to create the SSL directory for the certs.&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl&lt;br /&gt;
If keys and certs have not been created follow the instructions above. Assuming SSL dir creation is done we should make the site enabled &lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/strawberry.seaoffate.local /etc/nginx/sites-enabled/&lt;br /&gt;
We can test the config with &lt;br /&gt;
 sudo nginx -t&lt;br /&gt;
If all is well Restart Nginx to apply the changes&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 sudo systemctl status nginx&lt;br /&gt;
We can run a test with curl &lt;br /&gt;
 curl -v https://strawberry.seaoffate.local&lt;br /&gt;
We should also open a browser to see if it can open the website &lt;br /&gt;
 https://strawberry.seaoffate.local&lt;br /&gt;
&lt;br /&gt;
== webservers Purposes ==&lt;br /&gt;
&lt;br /&gt;
four webservers with the primary job of serving websites have been defined.&lt;br /&gt;
&lt;br /&gt;
===Logan (Wiki)===&lt;br /&gt;
&lt;br /&gt;
logan has been setup as a webserver to have the wiki website. It&#039; IP is prod.12 It can be accessed by logan.seaoffate.local, wiki.seaoffate.local or wiki.seaoffate.net&lt;br /&gt;
&lt;br /&gt;
===Lime (default)===&lt;br /&gt;
&lt;br /&gt;
The default website is hosted on lime. The IP is prod.10. It can be accessed by lime.seaoffate.local, www.seaoffate.local or www.seaoffate.local.&lt;br /&gt;
&lt;br /&gt;
===Fig (files)===&lt;br /&gt;
&lt;br /&gt;
not setup yet ip will is prod.11 &lt;br /&gt;
&lt;br /&gt;
===[[Plum (Photo)]]===&lt;br /&gt;
&lt;br /&gt;
This one is to host the photo website, probably Piwigo. It can be accessed at plum.seaoffate.local, photo.seaoffate.local or plum.seaoffate.net. The Ip will be Prod.22. The setup here is to have a normal HD for the webserver and a large separate HD for the photos. We may  VM called strawberry (IP prod.23).&lt;br /&gt;
&lt;br /&gt;
== Website log files and locations ==&lt;br /&gt;
&lt;br /&gt;
The Docroots are &lt;br /&gt;
 /var/www/wiki.seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/files.seaoffate.local/public_html&lt;br /&gt;
&lt;br /&gt;
The access logs are seperate for each config &lt;br /&gt;
&lt;br /&gt;
===www.seaoffate on Lime===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-access.log&lt;br /&gt;
and the local are&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===wiki.seaoffate on Logan===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-access.log&lt;br /&gt;
and the .local are &lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-access.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===Nginx Log Files===&lt;br /&gt;
&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=142</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=142"/>
		<updated>2025-03-13T05:29:45Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Plum (Photo) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There will be several Webservers in the &#039;&#039;&#039;[[Home Lab]]&#039;&#039;&#039;. Each will be on it&#039;s own &#039;&#039;&#039;[[Virtual Machines]]&#039;&#039;&#039; and will be on the production VLAN. The MySQL databases will be on a separate VM on the same network so no connectivity problems from that. The Proxy server will forward all web traffic to the appropriate webserver.&lt;br /&gt;
&lt;br /&gt;
==SSL Config==&lt;br /&gt;
&lt;br /&gt;
There will be two setups for SSL/TLS one for the seaoffate.local and one for seaoffate.net.&lt;br /&gt;
&lt;br /&gt;
===Local DNS Names SSL Setup===&lt;br /&gt;
&lt;br /&gt;
We will do the SSL/TLS for the .local access first mainly because because it is better to see it working on a local level and if we did the global first there is a good chance we would never get a around to doing the local, in which case some of the access will be completely without any cert. It is part of the learning curve to generate SSL certificates. While it would be fairly easier to do a self cert for the local access it is better to experience the whole process from start to finish to get a complete understanding of how it is done and the failures that inevitably appear. &lt;br /&gt;
&lt;br /&gt;
==== The Process Flow====&lt;br /&gt;
&lt;br /&gt;
The process flow is to get the Certificates generated on the webserver host, get it signed by the Certificate Authority then apply it to the webserver, once that is done the SSL config needs to be applied to the host, after that it we would make a config to the reverse proxy. The reverse proxy will have it&#039;s own certificate to use for all of the hosts that it is forwarding to and once the cert is applied it will not need to have it applied again, we would just refer to it in the individual SSL config.  &lt;br /&gt;
&lt;br /&gt;
====Generating SSL Certificates====&lt;br /&gt;
&lt;br /&gt;
The first thing to do is to generate a private key, this is done on the webserver with the command&lt;br /&gt;
 sudo openssl genrsa -out /etc/ssl/private/strawberry.seaoffate.local.key 2048&lt;br /&gt;
The out directive will specify where the private key will stored, in this case the default location is used. The .key does need to be stored  privately as it is the key that will be used to encrypt or decrypt the internet traffic and is the core item in the security of the Internet. Once the private key has been generated access should be restricted to the root user only so we need to do the chmod/chown commanda s follows&lt;br /&gt;
 sudo chmod 600 /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
 sudo chown root:root /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
Now that we have the private key we can look at getting the public certificate. To get the certificate with any sort of trust it has to be signed by a Certificate Authority. We have a personal CA available on Alpine, it will only be trusted by us and not the rest of the world as it is a personal CA. To have a cert signed we must generate a Certificate Signing Request and present it to the CA the command to generate a CSR is &lt;br /&gt;
 sudo openssl req -new -key /etc/ssl/private/strawberry.seaoffate.local.key -out /etc/ssl/certs/strawberry.seaoffate.local.csr&lt;br /&gt;
As this script executes it will ask a numer of questions.&lt;br /&gt;
* Country Name (2 letter code) [AU]:GB&lt;br /&gt;
* State or Province Name (full name) [Some-State]:Hampshire&lt;br /&gt;
* Locality Name (eg, city) []:Basingstoke&lt;br /&gt;
* Organization Name (eg, company) [Internet Widgits Pty Ltd]:Sea of Fate&lt;br /&gt;
* Organizational Unit Name (eg, section) []: (Your department or unit, if applicable, or leave blank)&lt;br /&gt;
* Common Name (e.g. server FQDN or YOUR name) []: strawberry.seaoffate.local (This is crucial, it must match the hostname)&lt;br /&gt;
* Email Address []:sailor@seaoffate.net&lt;br /&gt;
* A challenge password []: (Leave blank, or add a password, but it is not needed for webserver certificates)&lt;br /&gt;
* An optional company name []: (Leave blank, or add an optional company name)&lt;br /&gt;
&#039;&#039;&#039;Note that the Common Name is critical&#039;&#039;&#039; The other fields are not so important but should be accurate (don&#039;t lie someone may read them), the fields could be left blank (except common name). the challenge password is rarely used for webserver certs and can be left blank.&lt;br /&gt;
&lt;br /&gt;
Note that the command uses the  private key that we just generated. The CSR is added to the certs directory it is not secret but it should not be modified so it still need to be stored in a form that has at least 744 on it. As this is a signing request we have to get is to the signing software, the CA, in a secure manner. generally SCP is the best option to transfer a file securely as it uses the same connection as SSH. An example is  &lt;br /&gt;
 scp /etc/ssl/certs/strawberry.seaoffate.local.csr user@alpine:~/easy-rsa/easyrsa3/pki/reqs/&lt;br /&gt;
If this doesn&#039;t work with the user that is available try copying to /tmp&lt;br /&gt;
 scp /etc/ssl/certs/strawberry.seaoffate.local.csr user@alpine:/tmp&lt;br /&gt;
When the file is copied to Apline we must login to the Alpine host to do the signing. I the CSR file could not be added directly to the reqs directory it should be copied there now. &lt;br /&gt;
 cp /tmp/strawberry.seaoffate.local.csr ~/easy-rsa/easyrsa3/pki/reqs&lt;br /&gt;
Unfortunately, easyrsa need to see CSRs with the extension of .req but the openssl generates them as .csr the solution is to mv the .csr to .req &lt;br /&gt;
 mv ~/easy-rsa/easyrsa3/pki/reqs/strawberry.seaoffate.local.csr ~/easy-rsa/easyrsa3/pki/reqs/strawberry.seaoffate.local.req&lt;br /&gt;
Assuming that the CSR is in the /reqs directory and it has the correct extension we can proceed with the signing. We should be in the ~/easy-rsa/easyrsa3/ directory to run the script&lt;br /&gt;
 ./easyrsa sign-req server strawberry.seaoffate.local&lt;br /&gt;
the script will ask to confirm the details that would have been submitted when creating the signing request on the web host and the first answer has to be &amp;quot;yes&amp;quot; or it will not continue. The next question is to supply the passphrase for the script to have access to the CA.key, if it can&#039;t be given the request fails. Once the CSR/REQ has been signed the certificate will be created and stored in the issued directory and is ready to be returned to the webserver again using SCP. We could copy the .CRT directly to the /ect/ssl/certs dir on the web host but since we are using Ubuntu we can&#039;t because the permissions fail. We should create a dir off of the user&#039;s home dir and call it signed we can then SCP &lt;br /&gt;
 SCP ~/easy-rsa/easyrsa3/pki/issued/strawberry.seaoffate.local.crt user@strawberry.seaoffate.local:~/signed&lt;br /&gt;
When that is done swap back to the web host (strawberry) and mv the signed cert to the correct directory&lt;br /&gt;
 sudo mv signed/strawberry.seaoffate.local.crt /etc/ssl/certs/&lt;br /&gt;
We should set the permissions on the cert to be read only and owned by root&lt;br /&gt;
 sudo chmod 644 /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
 sudo chown root:root /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
As a final job we can verify that the cert and key match each other&lt;br /&gt;
 sudo openssl x509 -noout -modulus -in /etc/ssl/certs/strawberry.seaoffate.local.crt | sudo openssl sha256&lt;br /&gt;
 sudo openssl rsa -noout -modulus -in /etc/ssl/private/strawberry.seaoffate.local.key | sudo openssl sha256&lt;br /&gt;
check to make sure that the two hashes are identical, if they are not SSL will not work on the website.&lt;br /&gt;
&lt;br /&gt;
====Create Apache SSL Configuration====&lt;br /&gt;
&lt;br /&gt;
Now that we have a signed certificate we can proceed to configure Apache to listen &amp;amp; serve SSL/TLS request on port 443. As we have used Strawberry as the example for the cert generation we will continue to use the same host for the configs. First we should cd to the site-available so that the config file we create matches the existing and we get the correct docroot. We should create a config file,&lt;br /&gt;
 sudo nano /etc/apache2/sites-available/strawberry.seaoffate.local-ssl.conf&lt;br /&gt;
and enter the following&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName strawberry.seaoffate.local&lt;br /&gt;
    DocumentRoot /var/www/strawberry/public_html&lt;br /&gt;
&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/strawberry.seaoffate.local.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/strawberry.seaoffate.local.key&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;Directory /var/www/strawberry/public_html/&amp;gt;&lt;br /&gt;
        AllowOverride All&lt;br /&gt;
        Require all granted&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    # Security Headers (Recommended)&lt;br /&gt;
    Header always set Strict-Transport-Security &amp;quot;max-age=63072000; includeSubDomains; preload&amp;quot;&lt;br /&gt;
    Header always set X-Frame-Options &amp;quot;SAMEORIGIN&amp;quot;&lt;br /&gt;
    Header always set X-Content-Type-Options &amp;quot;nosniff&amp;quot;&lt;br /&gt;
    Header always set Referrer-Policy &amp;quot;strict-origin-when-cross-origin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # SSL Protocol and Cipher Configuration (Recommended)&lt;br /&gt;
    SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1&lt;br /&gt;
    SSLCipherSuite HIGH:!aNULL:!MD5&lt;br /&gt;
&lt;br /&gt;
    ErrorLog ${APACHE_LOG_DIR}/error.log&lt;br /&gt;
    CustomLog ${APACHE_LOG_DIR}/access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit. To enable the SSL site and enable the SSL modules.&lt;br /&gt;
  sudo a2ensite strawberry.seaoffate.local-ssl.conf&lt;br /&gt;
 sudo a2enmod ssl&lt;br /&gt;
 sudo a2enmod headers&lt;br /&gt;
To restart Apache &amp;amp; check for errors&lt;br /&gt;
 sudo systemctl restart apache2&lt;br /&gt;
 sudo systemctl status apache2&lt;br /&gt;
To test with curl &lt;br /&gt;
 curl -v https://strawberry.seaoffate.local&lt;br /&gt;
We should also look in a browser to be sure that the config works.&lt;br /&gt;
&lt;br /&gt;
==== Raisin Nginx Reverse Proxy Configuration====&lt;br /&gt;
&lt;br /&gt;
Once we have tested the webserver SSL config we should do the same for Raisin, the Reverse Proxy, First of all ssh to raisin and cd to /etc/nginx/sites-available to check what the format is for the existing configs. Create anew config for strawberry&lt;br /&gt;
 sudo nano strawberry.seaoffate.local.ssl.conf&lt;br /&gt;
fill in the following configuration&lt;br /&gt;
 server {&lt;br /&gt;
    listen 443 ssl;&lt;br /&gt;
    server_name strawberry.seaoffate.local;&lt;br /&gt;
&lt;br /&gt;
    ssl_certificate /etc/nginx/ssl/raisin.crt; # Path to your SSL certificate on raisin&lt;br /&gt;
    ssl_certificate_key /etc/nginx/ssl/raisin.key; # Path to your SSL key on raisin&lt;br /&gt;
&lt;br /&gt;
    ssl_protocols TLSv1.2 TLSv1.3;&lt;br /&gt;
    ssl_ciphers &#039;HIGH:!aNULL:!MD5&#039;; # !aNULL: This excludes ciphers that use anonymous Diffie-Hellman key exchange !MD5&#039; excludes weak md5 hash &lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass https://192.168.100.21; # IP of strawberry&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
        proxy_set_header X-Forwarded-Proto $scheme;&lt;br /&gt;
        proxy_ssl_verify off; # only needed if strawberry has a self signed cert.&lt;br /&gt;
    }&lt;br /&gt;
 }&lt;br /&gt;
Save and exit. If this is the first SSL website to be proxy, we will need to create the SSL directory for the certs.&lt;br /&gt;
 sudo mkdir -p /etc/nginx/ssl&lt;br /&gt;
If keys and certs have not been created follow the instructions above. Assuming SSL dir creation is done we should make the site enabled &lt;br /&gt;
 sudo ln -s /etc/nginx/sites-available/strawberry.seaoffate.local /etc/nginx/sites-enabled/&lt;br /&gt;
We can test the config with &lt;br /&gt;
 sudo nginx -t&lt;br /&gt;
If all is well Restart Nginx to apply the changes&lt;br /&gt;
 sudo systemctl restart nginx&lt;br /&gt;
 sudo systemctl status nginx&lt;br /&gt;
We can run a test with curl &lt;br /&gt;
 curl -v https://strawberry.seaoffate.local&lt;br /&gt;
We should also open a browser to see if it can open the website &lt;br /&gt;
 https://strawberry.seaoffate.local&lt;br /&gt;
&lt;br /&gt;
== webservers Purposes ==&lt;br /&gt;
&lt;br /&gt;
four webservers with the primary job of serving websites have been defined.&lt;br /&gt;
&lt;br /&gt;
===Logan (Wiki)===&lt;br /&gt;
&lt;br /&gt;
logan has been setup as a webserver to have the wiki website. It&#039; IP is prod.12 It can be accessed by logan.seaoffate.local, wiki.seaoffate.local or wiki.seaoffate.net&lt;br /&gt;
&lt;br /&gt;
===Lime (default)===&lt;br /&gt;
&lt;br /&gt;
The default website is hosted on lime. The IP is prod.10. It can be accessed by lime.seaoffate.local, www.seaoffate.local or www.seaoffate.local.&lt;br /&gt;
&lt;br /&gt;
===Fig (files)===&lt;br /&gt;
&lt;br /&gt;
not setup yet ip will is prod.11 &lt;br /&gt;
&lt;br /&gt;
===[[Plum (Photo)]]===&lt;br /&gt;
&lt;br /&gt;
This one is to host the photo website, probably Piwigo. It can be accessed at plum.seaoffate.local, photo.seaoffate.local or plum.seaoffate.net. The Ip will be Prod.22. The setup here is to have a normal HD for the webserver and a large separate HD for the photos. We may  VM called strawberry (IP prod.23).&lt;br /&gt;
&lt;br /&gt;
== Website log files and locations ==&lt;br /&gt;
&lt;br /&gt;
The Docroots are &lt;br /&gt;
 /var/www/wiki.seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/files.seaoffate.local/public_html&lt;br /&gt;
&lt;br /&gt;
The access logs are seperate for each config &lt;br /&gt;
&lt;br /&gt;
===www.seaoffate on Lime===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-access.log&lt;br /&gt;
and the local are&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===wiki.seaoffate on Logan===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-access.log&lt;br /&gt;
and the .local are &lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-access.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===Nginx Log Files===&lt;br /&gt;
&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
 DocumentRoot /var/www/files.seaoffate.local/public_html&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=External_Access&amp;diff=34</id>
		<title>External Access</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=External_Access&amp;diff=34"/>
		<updated>2025-03-01T15:48:41Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: Created page with &amp;quot;==Introduction==  I will want access to various hosts for file shares and configuration. This is where I will describe it.    ==SSH Access==  I will want access to the hosts inside the network not least the production hosts to continue the configuration while I am somewhere else. The problem is that Pfsense can only forward based on port so if I want to SSH to Lime from outside of the WAN port of Pfsense there is no way of the firewall from knowing that  mean Lime and no...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
I will want access to various hosts for file shares and configuration. This is where I will describe it. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==SSH Access==&lt;br /&gt;
&lt;br /&gt;
I will want access to the hosts inside the network not least the production hosts to continue the configuration while I am somewhere else. The problem is that Pfsense can only forward based on port so if I want to SSH to Lime from outside of the WAN port of Pfsense there is no way of the firewall from knowing that  mean Lime and not Lemon. I could setup a bastion host to forward on SSH to the various hosts and I may well set it up at a later date just so that I know how but it is a bit of overkill for such a small number hosts. I have instead chosen to have each host listen at a different port so all I need is to have a table showing which port to which host, it will still be secure as it will still be SSH but instead. I will still need a firewall port forward rule for each host internally i will only need one&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Home_Lab&amp;diff=33</id>
		<title>Home Lab</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Home_Lab&amp;diff=33"/>
		<updated>2025-03-01T15:30:18Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
The purpose of the home lab will be to provide a safe store for all of my pictures and videos. Also there will be a website to document my adventures, It will be contained within the [[Proxmox Server]]&lt;br /&gt;
&lt;br /&gt;
==[[Virtual Machines]]==&lt;br /&gt;
&lt;br /&gt;
There will be a collection of Virtual Machines, mostly Linux hosts partly because they are free but now that i have found a really cheap license seller the cost is less of a concern. Reliability is the other reason for basing the systems around Linux. The general setup is to have a Pfsense firewall at the central gateway to my network all of the rest of the servers being linked by it. There is already a Nameserver, a reverse proxy to allow access to Webservers. there will be a VPNserver to allow remote access to some Desktop VMs. There is a CA server so I can issue my own certs to the various computers that I use. There is a management kiosk that I am using to do most of the configuration, as it is not going to be easily access from outside it will keep all of the configuration inside Proxmox. More details of the  VMs can be found &#039;&#039;&#039;[[Virtual Machines | here]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==[[External Access]]==&lt;br /&gt;
&lt;br /&gt;
I want to allow access to some of the network from remote sites initially by SSH but also other means at a later date.&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=32</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=32"/>
		<updated>2025-03-01T15:18:25Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Website log files and locations ==&lt;br /&gt;
&lt;br /&gt;
The Docroots are &lt;br /&gt;
 /var/www/wiki.seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/files.seaoffate.local/public_html&lt;br /&gt;
&lt;br /&gt;
The access logs are seperate for each config &lt;br /&gt;
&lt;br /&gt;
===www.seaoffate on Lime===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-access.log&lt;br /&gt;
and the local are&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===wiki.seaoffate on Logan===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-access.log&lt;br /&gt;
and the .local are &lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-access.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===Nginx Log Files===&lt;br /&gt;
&lt;br /&gt;
DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
DocumentRoot /var/www/files.seaoffate.local/public_html&lt;br /&gt;
DocumentRoot /var/www/files.seaoffate.local/public_html&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=31</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=31"/>
		<updated>2025-03-01T10:03:31Z</updated>

		<summary type="html">&lt;p&gt;192.168.100.9: /* Website log files and locations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Website log files and locations ==&lt;br /&gt;
&lt;br /&gt;
The Docroots are &lt;br /&gt;
 /var/www/wiki.seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/seaoffate.local/public_html&lt;br /&gt;
and&lt;br /&gt;
 /var/www/files.seaoffate.local/public_html&lt;br /&gt;
&lt;br /&gt;
The access logs are seperate for each config &lt;br /&gt;
&lt;br /&gt;
===www.seaoffate on Lime===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/www.seaoffate.net-access.log&lt;br /&gt;
and the local are&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/lime.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===wiki.seaoffate on Logan===&lt;br /&gt;
&lt;br /&gt;
For the .net they are&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.net-access.log&lt;br /&gt;
and the .local are &lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/wiki.seaoffate.local-access.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-error.log&lt;br /&gt;
 /var/log/apache2/logan.seaoffate.local-access.log&lt;br /&gt;
&lt;br /&gt;
===Nginx Log Files===&lt;/div&gt;</summary>
		<author><name>192.168.100.9</name></author>
	</entry>
</feed>