<?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=Sailor</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=Sailor"/>
	<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php/Special:Contributions/Sailor"/>
	<updated>2026-06-05T22:39:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=565</id>
		<title>Pfsense</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=565"/>
		<updated>2025-07-13T15:38:56Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* VPNnet and Terminals */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Pfsense on Pear is designed to keep the virtual networks separate from the physical NIC. It is has an interface on each of the virtual networks and the WAN interface on the same  network as the physical NIC. The install does not have any plugins.&lt;br /&gt;
&lt;br /&gt;
==Interfaces==&lt;br /&gt;
&lt;br /&gt;
There several LAN networks including Production, Infra, VPNnet and terminals for the virtual machines to use. There is also another LAN called mgt that is reserved for management.&lt;br /&gt;
&lt;br /&gt;
===Production===&lt;br /&gt;
&lt;br /&gt;
The production network is reserved for the main production VMs, mainly Webhosts and hosts that support them. Juniper has also been moved to production as it will be hosting jellyfin and n8n.&lt;br /&gt;
&lt;br /&gt;
===Infra===&lt;br /&gt;
&lt;br /&gt;
Infra or infrastructure is used for the LAN services such as the nameserver and the monitoring hosts.&lt;br /&gt;
&lt;br /&gt;
===VPNnet and Terminals===&lt;br /&gt;
&lt;br /&gt;
The VPN servers are on VPMnet and the desktops are on Terminals. The desktops will probably be moved to production but the two VPN servers (Wireguard and Openvpn) will stay where they are as they need to be kept separate for security reasons.&lt;br /&gt;
&lt;br /&gt;
===MGT===&lt;br /&gt;
&lt;br /&gt;
This management network is highly restricted and reserved purely to do management functions, particularly for the management of the web GUI of pfsense which means that it is not possible to manage Pfsense from any remote computer, all Pfsense management must be done from the console while logged on to Pear. Also any other management should be done from the mgt network. To make this possible the VM host Lemon has been created with firefox and passwordless ssh to most relevant hosts. Keepass has also been installed to keep track of all passwords used on Pear.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=564</id>
		<title>Pfsense</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=564"/>
		<updated>2025-07-13T15:27:20Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* production */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Pfsense on Pear is designed to keep the virtual networks separate from the physical NIC. It is has an interface on each of the virtual networks and the WAN interface on the same  network as the physical NIC. The install does not have any plugins.&lt;br /&gt;
&lt;br /&gt;
==Interfaces==&lt;br /&gt;
&lt;br /&gt;
There several LAN networks including Production, Infra, VPNnet and terminals for the virtual machines to use. There is also another LAN called mgt that is reserved for management.&lt;br /&gt;
&lt;br /&gt;
===Production===&lt;br /&gt;
&lt;br /&gt;
The production network is reserved for the main production VMs, mainly Webhosts and hosts that support them. Juniper has also been moved to production as it will be hosting jellyfin and n8n.&lt;br /&gt;
&lt;br /&gt;
===Infra===&lt;br /&gt;
&lt;br /&gt;
Infra or infrastructure is used for the LAN services such as the nameserver and the monitoring hosts.&lt;br /&gt;
&lt;br /&gt;
===VPNnet and Terminals===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===MGT===&lt;br /&gt;
&lt;br /&gt;
This management network is highly restricted and reserved purely to do management functions, particularly for the management of the web GUI of pfsense which means that it is not possible to manage Pfsense from any remote computer, all Pfsense management must be done from the console while logged on to Pear. Also any other management should be done from the mgt network. To make this possible the VM host Lemon has been created with firefox and passwordless ssh to most relevant hosts. Keepass has also been installed to keep track of all passwords used on Pear.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=563</id>
		<title>Pfsense</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Pfsense&amp;diff=563"/>
		<updated>2025-07-13T15:26:59Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Pfsense on Pear is designed to keep the virtual networks separate from the physical NIC. It is has an interface on each of the virtual networks and the WAN interface on the same  network as the physical NIC. The install does not have any plugins.&lt;br /&gt;
&lt;br /&gt;
==Interfaces==&lt;br /&gt;
&lt;br /&gt;
There several LAN networks including Production, Infra, VPNnet and terminals for the virtual machines to use. There is also another LAN called mgt that is reserved for management.&lt;br /&gt;
&lt;br /&gt;
===production===&lt;br /&gt;
&lt;br /&gt;
The production network is reserved for the main production VMs, mainly Webhosts and hosts that support them. Juniper has also been moved to production as it will be hosting jellyfin and n8n.&lt;br /&gt;
&lt;br /&gt;
===Infra===&lt;br /&gt;
&lt;br /&gt;
Infra or infrastructure is used for the LAN services such as the nameserver and the monitoring hosts.&lt;br /&gt;
&lt;br /&gt;
===VPNnet and Terminals===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===MGT===&lt;br /&gt;
&lt;br /&gt;
This management network is highly restricted and reserved purely to do management functions, particularly for the management of the web GUI of pfsense which means that it is not possible to manage Pfsense from any remote computer, all Pfsense management must be done from the console while logged on to Pear. Also any other management should be done from the mgt network. To make this possible the VM host Lemon has been created with firefox and passwordless ssh to most relevant hosts. Keepass has also been installed to keep track of all passwords used on Pear.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Other_temporary_projects&amp;diff=261</id>
		<title>Other temporary projects</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Other_temporary_projects&amp;diff=261"/>
		<updated>2025-03-21T12:59:42Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Download another model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
My early investigations of AI with stable Diffusion. I will leave these early notes long past there date so my confusion can be seen and hopefully see some progression.&lt;br /&gt;
&lt;br /&gt;
==Using the GPU on My Windows 11 PC==&lt;br /&gt;
&lt;br /&gt;
I have downloaded the components to install the Stable Diffusion components. I installed Python but an early version (3.10.6) because I was told that it wouldn&#039;t work on the later versions, not sure how true that is but I did it anyway. I also installed github because it looks like that is required as well. The Stable Diffusion Web UI is Automatic1111 and if I want more models they have to match the Automatic1111 system.&lt;br /&gt;
&lt;br /&gt;
===Running In a Browser===  &lt;br /&gt;
&lt;br /&gt;
The first model has been installed and works inside a browser. To start it going we need to open a command prompt or git bash (remember git bash is like Linux bash) and cd to &lt;br /&gt;
 D:\stable-diffusion\stable-diffusion-webui&lt;br /&gt;
or if in the Git Bash&lt;br /&gt;
 /d/stable-diffusion\stable-diffusion-webui&lt;br /&gt;
from here you can call the webui-user.bat script by typing the following command and pressing Enter&lt;br /&gt;
 webui-user.bat&lt;br /&gt;
or if on Git Bash&lt;br /&gt;
 ./webui-user.bat&lt;br /&gt;
If there are updates &lt;br /&gt;
* The script will download any necessary updates and start the Web UI.&lt;br /&gt;
Once the process is complete, you&#039;ll see a message in the terminal with the local URL, Open the URL in your web browser. There shouldn&#039;t be any error messages but this still quite experimental so some update could easily break it.&lt;br /&gt;
&lt;br /&gt;
===Download another model===&lt;br /&gt;
&lt;br /&gt;
I also downloaded the comfyUI Windows portable cu126.7z.002 with models.zip.001 and followed instructions from https://github.com/YanWenKun/ComfyUI-Windows-Portable?tab=readme-ov-file. I named the directory comfyUIWindowsPortable however it would not extractfor the time being i will move on&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Other_temporary_projects&amp;diff=260</id>
		<title>Other temporary projects</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Other_temporary_projects&amp;diff=260"/>
		<updated>2025-03-21T11:31:54Z</updated>

		<summary type="html">&lt;p&gt;Sailor: Created page with &amp;quot;==Introduction==  My early investigations of AI with stable Diffusion. I will leave these early notes long past there date so my confusion can be seen and hopefully see some progression.  ==Using the GPU on My Windows 11 PC==  I have downloaded the components to install the Stable Diffusion components. I installed Python but an early version (3.10.6) because I was told that it wouldn&amp;#039;t work on the later versions, not sure how true that is but I did it anyway. I also inst...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
My early investigations of AI with stable Diffusion. I will leave these early notes long past there date so my confusion can be seen and hopefully see some progression.&lt;br /&gt;
&lt;br /&gt;
==Using the GPU on My Windows 11 PC==&lt;br /&gt;
&lt;br /&gt;
I have downloaded the components to install the Stable Diffusion components. I installed Python but an early version (3.10.6) because I was told that it wouldn&#039;t work on the later versions, not sure how true that is but I did it anyway. I also installed github because it looks like that is required as well. The Stable Diffusion Web UI is Automatic1111 and if I want more models they have to match the Automatic1111 system.&lt;br /&gt;
&lt;br /&gt;
===Running In a Browser===  &lt;br /&gt;
&lt;br /&gt;
The first model has been installed and works inside a browser. To start it going we need to open a command prompt or git bash (remember git bash is like Linux bash) and cd to &lt;br /&gt;
 D:\stable-diffusion\stable-diffusion-webui&lt;br /&gt;
or if in the Git Bash&lt;br /&gt;
 /d/stable-diffusion\stable-diffusion-webui&lt;br /&gt;
from here you can call the webui-user.bat script by typing the following command and pressing Enter&lt;br /&gt;
 webui-user.bat&lt;br /&gt;
or if on Git Bash&lt;br /&gt;
 ./webui-user.bat&lt;br /&gt;
If there are updates &lt;br /&gt;
* The script will download any necessary updates and start the Web UI.&lt;br /&gt;
Once the process is complete, you&#039;ll see a message in the terminal with the local URL, Open the URL in your web browser. There shouldn&#039;t be any error messages but this still quite experimental so some update could easily break it.&lt;br /&gt;
&lt;br /&gt;
===Download another model===&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Proxmox_Server&amp;diff=259</id>
		<title>Proxmox Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Proxmox_Server&amp;diff=259"/>
		<updated>2025-03-20T22:05:39Z</updated>

		<summary type="html">&lt;p&gt;Sailor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
This is the server that will sit under my desk until I move house.&lt;br /&gt;
&lt;br /&gt;
==[[Home Lab]]==&lt;br /&gt;
&lt;br /&gt;
The long term setup of Virtual Machines to keep things going. The main objective is is to have a self contained robust setup to allow me to leave the lab alone to hum away to itself and while i am away from home give me access to files and desktop PCs from any simple terminal that I happen to be near. [[Home Lab | More Details here]].&lt;br /&gt;
&lt;br /&gt;
==[[Create Virtual Machine from a template]]==&lt;br /&gt;
&lt;br /&gt;
it is possible to create a new VM based on a fixed template. The two possibilities are a full clone or a linked clone. the linked clone is the preferred as it should need less storage but the full clone would be completely independent of the template so it will use more storage and take longer to create.We can go down that rabbit hole when we look ant Ansible in a big way. For now just understand that we can call a new vm  using the  qm clone command. the will be more details to follow.&lt;br /&gt;
 &lt;br /&gt;
==[[Stable diffusion and AI]]==&lt;br /&gt;
&lt;br /&gt;
A rough guide to this confusing and sometime contradictory world of Stable Diffusion (at least it appears that way to me because I am only just starting on this project.&lt;br /&gt;
&lt;br /&gt;
==[[Other temporary projects]]==&lt;br /&gt;
&lt;br /&gt;
There are likely to be other projects that I can undertake.&lt;br /&gt;
&lt;br /&gt;
==Proxmox==&lt;br /&gt;
&lt;br /&gt;
===Hardware Specification===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
&lt;br /&gt;
====Access====&lt;br /&gt;
&lt;br /&gt;
The IP Address and port of the host is 192.168.0.110:8006. I have my virgin media router forwarding all incoming traffic to 192.168.0.125 so it will go directly to the Pfsense firewall. All of the terminals can also send traffic to the WAN port of Pfsense.&lt;br /&gt;
&lt;br /&gt;
====Storage====&lt;br /&gt;
&lt;br /&gt;
The main storage is the three 16TB hard drives configure into ZFS z1 so that they have one redundant disk. As one disk is redundant, obviously, it has 32TB of storage available.&lt;br /&gt;
&lt;br /&gt;
I couldn&#039;t get PCI passthrough to work reliably without significant effort and some expense so I set up ZFS on Proxmox itself or more precisely on the Debian Linux that Proxmox resides on. Unfortunately, that means that I have to do any config on the CLI. I may write some scripts to perform some of the admin tasks or more likely setup a Nginx container to automate as much of it as possible.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=UpLoad_Server&amp;diff=258</id>
		<title>UpLoad Server</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=UpLoad_Server&amp;diff=258"/>
		<updated>2025-03-17T09:07:04Z</updated>

		<summary type="html">&lt;p&gt;Sailor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
We need a method of easily getting image files uploaded from both LAN and Internet ready to be edited and displayed on the &#039;&#039;&#039;[[Webservers]]&#039;&#039;&#039;. For most of the webservers there will not be too many images to be uploaded so direct access with a FTPS server on the webserver host will be good enough. However, for the &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039; there will be a significant amount of images to be uploaded, it is after all the Piwgo photo webserver and some pre processing and backups will be needed. We expect to do the backups from &#039;&#039;&#039;[[Backup Server]]&#039;&#039;&#039;. There will be some changes to the backup server/plum webserver to reverse the storage we will have to change the documentation for them as well.&lt;br /&gt;
&lt;br /&gt;
==Photo Management ==&lt;br /&gt;
&lt;br /&gt;
The general idea is to have an upload server as a staging point to get rid of duplicates, organise metatags and maybe enhance some of the photos and eventually transfer to the Piwigo website on &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039;, we will separate these duties on to this server. To make it all a self contained object we will make this a desktop Unbuntu install rather than the usual server installs. It is uncertain if that is going to be fast enough to actually edit photos but it should be good enough to edit any metatags.&lt;br /&gt;
&lt;br /&gt;
===Workflow Outline===&lt;br /&gt;
&lt;br /&gt;
The first thing to do is to dump all photos on the physical desktop PC on the 4tb drive it doesn&#039;t matter if there are duplicates as they will be addressed as part of this workflow. The important thing is to make sure there are none missing. Once there are photos to upload simply copy them to Satsuma via the SMB shares Import Export, they have been mapped to a pair of network drives (S: is Import and T: is Export). These network shares are on SMB so will only ever work on the LAN and they have been blocked from the internet. The photos are on Satsuma dir /mnt/images/Import and /mnt/images/Export. Once the files are on Satsuma they will be checked for duplicates and previously known, all new unique files will be moved to a separate input directory for processing by Digikam. When there are a few photos the user can login to the plum desktop and start Digikam (I was going to use Shotwell but it would appear that Digikam is a better fit). Digikam should pull the photos an copy them in to its own directory. The user edits the photos or adds tags to them and when finished they should be exported to another staging area to be sent to &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039;. While this leaves us with several copies of the same photos we should be able to have a script periodically delete the various copies, as a long term feature the photos will be left on the Digikam working directory (it is likely that Digikam will show loads of errors if it&#039;s working directory is cleared). The running of the various scripts will be tracked with some XML log files to cope with errors. The main processes flow will be tracked by a full database on Mandarin the [[MySQL Server]]. Once Photos are added to the final staging area a script will copy them on to &#039;&#039;&#039;[[Plum (Photo)]]&#039;&#039;&#039;. As they appear on Plum the photos can be displayed or not as defined by the Piwigo software. Also the photos will be copied by the &#039;&#039;&#039;[[Backup Server]]&#039;&#039;&#039; Strawberry from a NFS share from Plum to Offsite backup.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Satsuma Setup==&lt;br /&gt;
&lt;br /&gt;
Satsuma is a Ubuntu desktop install to allow for some graphical applications to be run, we will have to see how well that runs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Samba Install &amp;amp; A ZFS Hard Drive===&lt;br /&gt;
&lt;br /&gt;
To allow photos to be uploaded in the simplest method is to use SMB protocol and then setup network drives on any windows PC. It should be noted that SMB is not very secure so it should only be allowed on the LAN and make appropriate rules in the firewall.  To install Samba log in to the host Satsuma&lt;br /&gt;
 sudo apt update&lt;br /&gt;
 sudo apt install samba&lt;br /&gt;
&lt;br /&gt;
Setup a drive for samba to use by adding a separate drive in Proxmox from one of the ZFS datasets. Then start and login to the VM Satsuma. once we are logged in we need to identify the disk so run&lt;br /&gt;
 lsblk&lt;br /&gt;
Look through the listings for the block devices to identify the new disk. Look for the new disk (e.g., /dev/sdb). The output will show the UUID (e.g., UUID=&amp;quot;a1b2c3d4-e5f6-7890-1234-567890abcdef&amp;quot; Use fdisk to create a partition on the disk. &lt;br /&gt;
 sudo fdisk /dev/sdb &lt;br /&gt;
Replace /dev/sdb with your disk. Inside fdisk:&lt;br /&gt;
* n (New partition)&lt;br /&gt;
* p (Primary partition)&lt;br /&gt;
* 1 (Partition number 1)&lt;br /&gt;
* Enter (Default first sector)&lt;br /&gt;
* Enter (Default last sector)&lt;br /&gt;
* w (Write changes and exit) &lt;br /&gt;
When that is done we need to format. To Format the partition with ext4 filesystem:&lt;br /&gt;
 sudo mkfs.ext4 /dev/sdb1 # Replace /dev/sdb1 with your partition&lt;br /&gt;
We will now need to crate the mount point&lt;br /&gt;
 sudo mkdir /mnt/images&lt;br /&gt;
To use the partition UUID to mount it:&lt;br /&gt;
 sudo mount UUID=&amp;quot;YOUR_PARTITION_UUID&amp;quot; /mnt/images &lt;br /&gt;
# Replace with your YOUR_PARTITION_UUID&lt;br /&gt;
The mount like this will disappear on reboot so to make the mount persistent we would need to edit the /etc/fstab&lt;br /&gt;
 sudo nano /etc/fstab&lt;br /&gt;
WE need to add the line&lt;br /&gt;
UUID=&amp;quot;YOUR_PARTITION_UUID&amp;quot; /mnt/images ext4 defaults 0 2 # Replace with your UUID&lt;br /&gt;
Save and close the file&lt;br /&gt;
now the drive is set and formated we need to add the dirs for Samba to use&lt;br /&gt;
 sudo mkdir /mnt/images/import&lt;br /&gt;
 sudo mkdir /mnt/images/export&lt;br /&gt;
if the group photoshare has not been created yet &lt;br /&gt;
 sudo groupadd -g 1002 photoshare&lt;br /&gt;
If the users aren&#039;t yet created&lt;br /&gt;
 sudo useradd -u 1001 -g photoshare -m photoup&lt;br /&gt;
* -u 1001: Sets the UID to 1001&lt;br /&gt;
* -g photoshare: Sets the primary group to photoshare&lt;br /&gt;
* -m photoup: Creates the user&#039;s home directory.&lt;br /&gt;
 sudo passwd photoup (set a password for the user)&lt;br /&gt;
add the users to photoshare&lt;br /&gt;
 sudo usermod -aG photoshare nigel&lt;br /&gt;
 sudo usermod -aG photoshare photoup&lt;br /&gt;
If you need photoup to have sudo privileges for installing software or system administration: &lt;br /&gt;
 sudo usermod -aG sudo photoup&lt;br /&gt;
Then we can set the permissions of the drive&lt;br /&gt;
 sudo chown nigel:photoshare /mnt/images/export&lt;br /&gt;
 sudo chown nigel:photoshare /mnt/images/import&lt;br /&gt;
and allow full access&lt;br /&gt;
 sudo chmod 765 /mnt/images/import&lt;br /&gt;
 sudo chmod 765 /mnt/images/export&lt;br /&gt;
now that the users are ready and the had drive has been added and configured we can setup Samba&lt;br /&gt;
 sudo nano /etc/samba/smb.conf&lt;br /&gt;
Scroll down towards the bottom and add &lt;br /&gt;
[Import]&lt;br /&gt;
        comment = Share for importing files&lt;br /&gt;
        path = /mnt/images/import&lt;br /&gt;
        browseable = yes&lt;br /&gt;
        read only = no&lt;br /&gt;
        guest ok = no&lt;br /&gt;
        valid users = nigel, photoup # Users with import permissions&lt;br /&gt;
        create mask = 0664 # Permissions for new files&lt;br /&gt;
        directory mask = 0775 # Permissions for new directories&lt;br /&gt;
&lt;br /&gt;
[Export]&lt;br /&gt;
        comment = Share for exporting files&lt;br /&gt;
        path = /mnt/images/export&lt;br /&gt;
        browseable = yes&lt;br /&gt;
        read only = yes # Export share is read-only&lt;br /&gt;
        guest ok = no&lt;br /&gt;
        valid users = nigel, photoup # Users with export permissions&lt;br /&gt;
&lt;br /&gt;
Save and close the file then restart Samba&lt;br /&gt;
 sudo systemctl restart smbd&lt;br /&gt;
Set the password within Samba&lt;br /&gt;
 sudo smbpasswd -a photoup&lt;br /&gt;
 sudo smbpasswd -a nigel&lt;br /&gt;
&lt;br /&gt;
We will now need to add a rule to Pfsense in fact two rules, one for port 139 and another for 445. We should create aliases for the relevant values. so logon to Pfsense and go to firewall-&amp;gt;aliases and add the following&lt;br /&gt;
* alias IP_Samba should be set to the IP Address of the Samba server this would be the host satsuma&lt;br /&gt;
* alias Samba_high is set to the port 445&lt;br /&gt;
* alias Samba_low is set to 139&lt;br /&gt;
We will need to now add the two rules for Samba. Logon to the Pfsense and select Firewall-&amp;gt;Nat and click the add a rule button. The rule should be&lt;br /&gt;
* Interface should be WAN&lt;br /&gt;
* Protocol is TCP&lt;br /&gt;
* Source should be network and 192.168.0.0/24&lt;br /&gt;
* Source Port should be any&lt;br /&gt;
* Destination should be This firewall (self)&lt;br /&gt;
* Destination Port Range is Other-&amp;gt;Samba_Low to Other-&amp;gt;Samba_low&lt;br /&gt;
* Redirect Target IP should be Address or alias-&amp;gt;IP_Samba&lt;br /&gt;
* Redirect Target port should be Samba_Low&lt;br /&gt;
* Description should be something like Forward samba to samba server&lt;br /&gt;
* NAT reflection should be Enable (NAT + Proxy&lt;br /&gt;
* Filter Rule association should be create new associated filter rule ( note this will change when the rule is written to be the same as the comment)&lt;br /&gt;
Then save. Create another rule exactly the same but with Samba_high as the port.&lt;br /&gt;
&lt;br /&gt;
We are now ready for testing in Windows 11 Pro. On the desktop of the PC open the start menu and type notepad then open it with administrator. &lt;br /&gt;
* Select open file &lt;br /&gt;
* In the open dialog select the address C:\Windows\System32\drivers\etc&lt;br /&gt;
* In the file type box select all files&lt;br /&gt;
* select hosts&lt;br /&gt;
* scroll down to the bottom of the file and add the line &lt;br /&gt;
 192.168.0.x   photo # add the actual IP address of the Pfsense WAN port and if a different name to photo if required&lt;br /&gt;
* save as the file then change the file type to All files (*.*)&lt;br /&gt;
* from the Start menu type cmd and open as administrator&lt;br /&gt;
* type net use T: \\Photo\Export /user:satsuma\photoup photoupsPassword /persistant:yes ( this will map a network drive to T: the share will be at photo and the directory will be Export (it will be case sensitive and must match the [Export] block in Samba.conf), Photo will be whatever you put in hosts or could be changed to the IP address of the WAN port of Pfsense the user will be the Samba user and that must be on satsuma the password will also come from satsuma, if the hostname is less desirable then satsuma&#039;s ip address could be used, Persistent:Yes means the drive will be persevered on reboot of the PC.&lt;br /&gt;
* type net use S: \\Photo\Import /user:satsuma\photoup photoupsPassword /persistant:yes ( this will map a network drive to T: the share will be at photo and the directory will be Export (it will be case sensitive and must match the [Export] block in Samba.conf), Photo will be whatever you put in hosts or could be changed to the IP address of the WAN port of Pfsense the user will be the Samba user and that must be on satsuma the password will also come from satsuma, if the hostname is less desirable then satsuma&#039;s ip address could be used, Persistent:Yes means the drive will be persevered on reboot of the PC.&lt;br /&gt;
* Open Windows Explorer &lt;br /&gt;
* Browse to This PC and you should see two new drives one called Import and the other called Export. You should be able to add files to Import but Export will be just for export so will not be readable.&lt;br /&gt;
&lt;br /&gt;
==Setting up the Scripts==&lt;br /&gt;
&lt;br /&gt;
It is likely that there will be duplicate files uploaded because there are duplicate file stores that have been used over the years. To eliminate these duplicate files we will do a SHA256 on each after it has been uploaded to the import directory and compare the result to a database of previously stored files. while this sound really simple there will be some complexities that will be discovered along the way. The first obvious hurdle is what to do with any duplicates found I think the best solution will be to move them to different dirs depending on what their status is.&lt;br /&gt;
&lt;br /&gt;
===Directories and their uses===&lt;br /&gt;
&lt;br /&gt;
To keep things organised we will have several directories on the Images partition. All of the following will be dirs that have /mnt/images/ as their root&lt;br /&gt;
* import will be where Images are uploaded to as they come in to the system it will be messy and chaotic with the potential of having loads of duplicate files in different dirs.&lt;br /&gt;
* export will be for export of probably other files not related to the photo store.&lt;br /&gt;
* duplicates be a dumping ground for duplicates found prior to them being discarded.&lt;br /&gt;
* working will be a where each file will be moved to while it is being processed this dir will only ever have one file in it.&lt;br /&gt;
* digikam this will be the base Digikam directory&lt;br /&gt;
* /digikam/dk_import will be the directory that Digikam imports from&lt;br /&gt;
* /digikam/dk_thumbs will be the storage for digikam&#039;s  thumb nails&lt;br /&gt;
&lt;br /&gt;
==Processing with Digikam==&lt;br /&gt;
&lt;br /&gt;
I will process the images with Digikam either with the VM or with the desktop to make the two have synchronised databases we would have had a DB on on Mandarin but the is a security risk of allowing remote connections that we would have mitigated by limiting connections to localhost but that would have broken the connections to the webservers so the next best thing is to have a dedicated instance of MySQL on Satsuma (this host).&lt;br /&gt;
&lt;br /&gt;
===Install MySQL on Satsuma===&lt;br /&gt;
&lt;br /&gt;
We will install MySQL on Satsuma and limit it to local connection only. first things first&lt;br /&gt;
 sudo apt update&lt;br /&gt;
 sudo apt install mariadb-server&lt;br /&gt;
To secure the new install &lt;br /&gt;
 sudo mysql_secure_installation&lt;br /&gt;
* set strong root password&lt;br /&gt;
* remove anonymous users&lt;br /&gt;
* remove anonymous users&lt;br /&gt;
at the end of the questions it will logout the root user so Log in to the MySQL server:&lt;br /&gt;
 sudo mysql -u root -p &lt;br /&gt;
Create a user for Digikam:&lt;br /&gt;
 CREATE USER &#039;digikam_user&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;your_password&#039;&lt;br /&gt;
Create some databases for digikam to use&lt;br /&gt;
 CREATE DATABASE digikam;&lt;br /&gt;
 CREATE DATABASE digikam_core;&lt;br /&gt;
 CREATE DATABASE digikam_thumbs;&lt;br /&gt;
 CREATE DATABASE digikam_faces;&lt;br /&gt;
 CREATE DATABASE digikam_similarity;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON digikam.* TO &#039;digikam_user&#039;@&#039;localhost&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON digikam_core.* TO &#039;digikam_user&#039;@&#039;localhost&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON digikam_thumbs.* TO &#039;digikam_user&#039;@&#039;localhost&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON digikam_faces.* TO &#039;digikam_user&#039;@&#039;localhost&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON digikam_similarity.* TO &#039;digikam_user&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 EXIT;&lt;br /&gt;
&lt;br /&gt;
===Configure MySQL Over SSH===&lt;br /&gt;
&lt;br /&gt;
There are two options for allowing a client outside the firewall to connect to Mandarin&#039;s MySQL one is to forward the port directly but that has some security implications in that exposing MySQL to outside the LAN is not advisable. The other possibility is to share a SSH session between the inside and outside. There is still a small security consideration in that we will allow an SSH session through the firewall but that is an acceptable risk, given that we are already allowing SSH connections from outside and the firewall already has port forwarding in place. As noted on the external connections page  we port forward xxxx01 for  mandarin.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Importing and procesing==&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=257</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=257"/>
		<updated>2025-03-16T23:17:27Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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;
 sudo 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 permissions &amp;amp; ownership to the apache user&lt;br /&gt;
 sudo chown -R www-data:www-data /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
 sudo chmod 755 -R /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
&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. The Details that need to be entered on the web install are:&lt;br /&gt;
* For the database Hostname is the IP of Mandarin 192.168.100.8&lt;br /&gt;
* For the username it will be as was entered in the DB setup earlier piwigo_user&lt;br /&gt;
* For the password it should be on the keepass under piwigo mysql user&lt;br /&gt;
* The database name will also be the name setup earlier piwigo_db&lt;br /&gt;
* Administration configuration username should be stored in the keepass password manager&lt;br /&gt;
* Get the password from the same as username &lt;br /&gt;
* use sailor@seaoffate.net as this should be redirected by Cloudflare&lt;br /&gt;
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/galleries.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=256</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=256"/>
		<updated>2025-03-16T23:12:57Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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;
 sudo 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 permissions &amp;amp; ownership to the apache user&lt;br /&gt;
 sudo chown -R www-data:www-data /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
 sudo chmod 755 -R /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
&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. The Details that need to be entered on the web install are:&lt;br /&gt;
* For the database Hostname is the IP of Mandarin 192.168.100.8&lt;br /&gt;
* For the username it will be as was entered in the DB setup earlier piwigo_user&lt;br /&gt;
* For the password it should be on the keepass under piwigo mysql user&lt;br /&gt;
* The database name will also be the name setup earlier piwigo_db&lt;br /&gt;
* Administration configuration username should be stored in the keepass password manager&lt;br /&gt;
* Get the password from the same as username &lt;br /&gt;
* use sailor@seaoffate.net as this should be redirected by Cloudflare&lt;br /&gt;
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/galleries.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=255</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=255"/>
		<updated>2025-03-16T22:57:26Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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;
 sudo 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 permissions &amp;amp; ownership to the apache user&lt;br /&gt;
 sudo chown -R www-data:www-data /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
 sudo chmod 755 -R /var/www/plum.seaoffate.local/public_html/&lt;br /&gt;
&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=254</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=254"/>
		<updated>2025-03-16T22:53:37Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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;
 sudo 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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=251</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=251"/>
		<updated>2025-03-16T08:51:04Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=250</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=250"/>
		<updated>2025-03-16T08:23:37Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=249</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=249"/>
		<updated>2025-03-16T06:53:41Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 config on apache. We are going to be referring to the website as photo.seaoffate.net, photo.seaoffate.local and plum.seaoffate.local and this will setup all three both as http: and https: disable the default website and enable the photo websites with&lt;br /&gt;
 sudo a2dissite 000-default.conf&lt;br /&gt;
 sudo a2ensite photo.seaoffate.local.conf photo.seaoffate.net.conf plum.seaoffate.local.conf&lt;br /&gt;
 sudo systemctl reload apache2 &lt;br /&gt;
 sudo systemctl status apache2&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=248</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=248"/>
		<updated>2025-03-15T06:17:30Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
 #&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=247</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=247"/>
		<updated>2025-03-15T06:15:57Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
 #&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=246</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=246"/>
		<updated>2025-03-15T06:15:02Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
 #&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/nowiki&amp;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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=245</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=245"/>
		<updated>2025-03-15T06:13:17Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
 #&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&amp;quot;&lt;br /&gt;
&amp;lt;/nowiki&amp;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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=244</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=244"/>
		<updated>2025-03-15T06:11:15Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
 #&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
 #&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
 #&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 #&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
 #&lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 #&lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=243</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=243"/>
		<updated>2025-03-15T06:08:38Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
  #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
  #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=242</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=242"/>
		<updated>2025-03-15T06:02:21Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
 #!/bin/bash&lt;br /&gt;
&lt;br /&gt;
 # Script to create Apache configuration files for a website.&lt;br /&gt;
&lt;br /&gt;
 # Get website name from user input&lt;br /&gt;
 read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
&lt;br /&gt;
 # Get the hostname of the vm&lt;br /&gt;
 hostname=$(hostname)&lt;br /&gt;
&lt;br /&gt;
 # Define document root&lt;br /&gt;
 docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create directory structure&lt;br /&gt;
 mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
 echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Set permissions and ownership&lt;br /&gt;
 chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
 echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create index.php&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
 \$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
 date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
 \$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
 date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
 \$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
 &amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
 &amp;lt;html&amp;gt;&lt;br /&gt;
 &amp;lt;head&amp;gt;&lt;br /&gt;
 &amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
 &amp;lt;style&amp;gt;&lt;br /&gt;
 body {&lt;br /&gt;
   display: flex;&lt;br /&gt;
   justify-content: center;&lt;br /&gt;
   align-items: center;&lt;br /&gt;
   height: 100vh;&lt;br /&gt;
   margin: 0;&lt;br /&gt;
   font-family: sans-serif;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 #time-container {&lt;br /&gt;
   text-align: center;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 #uk-time, #spain-time, #ny-time {&lt;br /&gt;
   font-size: 24px;&lt;br /&gt;
   margin: 10px;&lt;br /&gt;
 }&lt;br /&gt;
 &amp;lt;/style&amp;gt;&lt;br /&gt;
 &amp;lt;/head&amp;gt;&lt;br /&gt;
 &amp;lt;body&amp;gt; &lt;br /&gt;
&lt;br /&gt;
 &amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
   &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
 &amp;lt;/div&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
 &amp;lt;/body&amp;gt;&lt;br /&gt;
 &amp;lt;/html&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 # Create Apache configuration files&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${website_name}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot; &lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
 &amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
     ServerName ${hostname}.seaoffate.local&lt;br /&gt;
     DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
     SSLEngine on&lt;br /&gt;
     SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
     SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
     ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
     CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
 &amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 #Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
 sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
 echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
 echo &amp;quot;All configuration files created and corrected.&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=241</id>
		<title>Webserver Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webserver_Setup&amp;diff=241"/>
		<updated>2025-03-15T05:57:49Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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. Back to the main page &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039; &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;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
# Script to create Apache configuration files for a website.&lt;br /&gt;
&lt;br /&gt;
# Get website name from user input&lt;br /&gt;
read -p &amp;quot;Enter website name: &amp;quot; website_name&lt;br /&gt;
&lt;br /&gt;
# Get the hostname of the vm&lt;br /&gt;
hostname=$(hostname)&lt;br /&gt;
&lt;br /&gt;
# Define document root&lt;br /&gt;
docroot=&amp;quot;/var/www/${website_name}.seaoffate.net/public_html&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create directory structure&lt;br /&gt;
mkdir -p &amp;quot;$docroot&amp;quot;&lt;br /&gt;
echo &amp;quot;Directory structure created: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Set permissions and ownership&lt;br /&gt;
chown -R www-data:www-data &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
chmod -R 755 &amp;quot;/var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
echo &amp;quot;Permissions and ownership set for: /var/www/${website_name}.seaoffate.net&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create index.php&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;$docroot/index.php&amp;quot;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
date_default_timezone_set(&#039;Europe/London&#039;);&lt;br /&gt;
\$ukTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
date_default_timezone_set(&#039;Europe/Madrid&#039;);&lt;br /&gt;
\$spainTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
&lt;br /&gt;
date_default_timezone_set(&#039;America/New_York&#039;);&lt;br /&gt;
\$nyTime = date(&#039;l, F j, Y, g:i:s A&#039;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
&amp;lt;title&amp;gt;Time Display&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;style&amp;gt;&lt;br /&gt;
body {&lt;br /&gt;
  display: flex;&lt;br /&gt;
  justify-content: center;&lt;br /&gt;
  align-items: center;&lt;br /&gt;
  height: 100vh;&lt;br /&gt;
  margin: 0;&lt;br /&gt;
  font-family: sans-serif;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#time-container {&lt;br /&gt;
  text-align: center;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#uk-time, #spain-time, #ny-time {&lt;br /&gt;
  font-size: 24px;&lt;br /&gt;
  margin: 10px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/style&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div id=&amp;quot;time-container&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;uk-time&amp;quot;&amp;gt;UK (London): &amp;lt;?php echo \$ukTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;spain-time&amp;quot;&amp;gt;Spain (Madrid): &amp;lt;?php echo \$spainTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
  &amp;lt;div id=&amp;quot;ny-time&amp;quot;&amp;gt;New York: &amp;lt;?php echo \$nyTime; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
echo &amp;quot;index.php created in: $docroot&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Create Apache configuration files&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.local.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.local.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${website_name}.seaoffate.net.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${website_name}.seaoffate.net&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${website_name}.seaoffate.net.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${website_name}.seaoffate.net.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${website_name}.seaoffate.net-ssl-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${website_name}.seaoffate.net-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:80&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;HTTP config created: /etc/apache2/sites-available/${hostname}.seaoffate.local.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cat &amp;lt;&amp;lt;EOF &amp;gt; &amp;quot;/etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&amp;lt;VirtualHost *:443&amp;gt;&lt;br /&gt;
    ServerName ${hostname}.seaoffate.local&lt;br /&gt;
    DocumentRoot &amp;quot;$docroot&amp;quot;&lt;br /&gt;
    SSLEngine on&lt;br /&gt;
    SSLCertificateFile /etc/ssl/certs/${hostname}.seaoffate.local.crt&lt;br /&gt;
    SSLCertificateKeyFile /etc/ssl/private/${hostname}.seaoffate.local.key&lt;br /&gt;
    ErrorLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-error.log&lt;br /&gt;
    CustomLog \${APACHE_LOG_DIR}/${hostname}.seaoffate.local-ssl-access.log combined&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
EOF&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;HTTPS config created: /etc/apache2/sites-available/${hostname}.seaoffate.local-ssl.conf&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#Remove the backslashes from the APACHE_LOG_DIR variable&lt;br /&gt;
sed -i &#039;s/\\\${APACHE_LOG_DIR}/${APACHE_LOG_DIR}/g&#039; /etc/apache2/sites-available/*.conf&lt;br /&gt;
echo &amp;quot;Removed backslashes from APACHE_LOG_DIR in config files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;All configuration files created and corrected.&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=240</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=240"/>
		<updated>2025-03-15T03:44:16Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 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 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 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 config on apache. We are going to be referring to the website as photo.seaoffate.net, photo.seaoffate.local and plum.seaoffate.local and this will setup all three both as http: and https: disable the default website and enable the photo websites with&lt;br /&gt;
 sudo a2dissite 000-default.conf&lt;br /&gt;
 sudo a2ensite photo.seaoffate.local.conf photo.seaoffate.net.conf plum.seaoffate.local.conf&lt;br /&gt;
 sudo systemctl reload apache2 &lt;br /&gt;
 sudo systemctl status apache2&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=239</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=239"/>
		<updated>2025-03-15T03:05:47Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 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 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 apache_config.sh&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=238</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=238"/>
		<updated>2025-03-15T03:04:08Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Introduction */&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 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 apache_config.sh &lt;br /&gt;
 sudo chown nigel:nigel lamp_client_install.sh&lt;br /&gt;
 sudo chmod 775 lamp_client_install.sh&lt;br /&gt;
 sudo chmod 755 apache_config.sh&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=237</id>
		<title>Plum (Photo)</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Plum_(Photo)&amp;diff=237"/>
		<updated>2025-03-15T01:58:48Z</updated>

		<summary type="html">&lt;p&gt;Sailor: Replaced content with &amp;quot;==Introduction==  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 hard drive for it&amp;#039;s OS as normal but read only access to the photo archive.&amp;quot;&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 hard drive for it&#039;s OS as normal but read only access to the photo archive.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=236</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=236"/>
		<updated>2025-03-15T01:56:50Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* SSL Config */&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. There are a few helpful scripts that can help with &#039;&#039;&#039;[[Webserver Setup | Webserver Setup Scripts]]&#039;&#039;&#039;&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. More details can be found &#039;&#039;&#039;[[SSL Config | here]]&#039;&#039;&#039;&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=SSL_Config&amp;diff=235</id>
		<title>SSL Config</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=SSL_Config&amp;diff=235"/>
		<updated>2025-03-15T01:53:36Z</updated>

		<summary type="html">&lt;p&gt;Sailor: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Intoduction==&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;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=SSL_Config&amp;diff=234</id>
		<title>SSL Config</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=SSL_Config&amp;diff=234"/>
		<updated>2025-03-15T01:49:14Z</updated>

		<summary type="html">&lt;p&gt;Sailor: Created page with &amp;quot;==Intoduction==  ==The Process == There will be two setups for SSL/TLS one for the seaoffate.local and one for seaoffate.net.  ===Local DNS Names SSL Setup===  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 lea...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Intoduction==&lt;br /&gt;
&lt;br /&gt;
==The Process ==&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;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=233</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=233"/>
		<updated>2025-03-15T01:47:35Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* SSL Config */&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. There are a few helpful scripts that can help with &#039;&#039;&#039;[[Webserver Setup | Webserver Setup Scripts]]&#039;&#039;&#039;&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=232</id>
		<title>Webservers</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Webservers&amp;diff=232"/>
		<updated>2025-03-15T01:46:05Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Introduction */&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. There are a few helpful scripts that can help with &#039;&#039;&#039;[[Webserver Setup | Webserver Setup Scripts]]&#039;&#039;&#039;&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>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=231</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=231"/>
		<updated>2025-03-15T01:44:57Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 | Webserver Setup Scripts]]===&lt;br /&gt;
&lt;br /&gt;
Some Apache and Gninx scrips to speed up creation and deployment of &#039;&#039;&#039;[[Webservers]]&#039;&#039;&#039;. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=230</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=230"/>
		<updated>2025-03-15T01:43:06Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of &#039;&#039;&#039;[[Webservers]]&#039;&#039;&#039;. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=229</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=229"/>
		<updated>2025-03-15T01:40:43Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* list_dns_entries.sh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==Add a DNS Record==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==List All DNS Entries==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=228</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=228"/>
		<updated>2025-03-15T01:40:03Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* add_dns_record,sh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==Add a DNS Record==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==list_dns_entries.sh==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=227</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=227"/>
		<updated>2025-03-15T01:39:02Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Delete a Record */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==add_dns_record,sh==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==list_dns_entries.sh==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=226</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=226"/>
		<updated>2025-03-15T01:38:46Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* list_dns_entries.sh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==add_dns_record,sh==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==list_dns_entries.sh==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=225</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=225"/>
		<updated>2025-03-15T01:38:28Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* add_dns_record,sh */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==add_dns_record,sh==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==list_dns_entries.sh==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=224</id>
		<title>Add a Hostname &amp; IP Address to DNSmsaq</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Add_a_Hostname_%26_IP_Address_to_DNSmsaq&amp;diff=224"/>
		<updated>2025-03-15T01:37:58Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
There are a few scripts that will help with the management of the DNSmasq install on NS1. We can get back to the main VM section &#039;&#039;&#039;[[Virtual Machines#Installation Scripts | here]]&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Details of the script==&lt;br /&gt;
&lt;br /&gt;
==add_dns_record,sh==&lt;br /&gt;
&lt;br /&gt;
There is a script that can be run to add a dns record to dnsmasq&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The code for the script &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;br /&gt;
 #&lt;br /&gt;
&lt;br /&gt;
==list_dns_entries.sh==&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to list all DNS entries from dnsmasq configuration files with aligned IP addresses.&lt;br /&gt;
 #&lt;br /&gt;
 # Directory containing dnsmasq configuration files&lt;br /&gt;
 DNSMASQ_DIR=&amp;quot;/etc/dnsmasq.d/&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the directory exists&lt;br /&gt;
 if [ ! -d &amp;quot;$DNSMASQ_DIR&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Error: Directory &#039;$DNSMASQ_DIR&#039; not found.&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Function to calculate padding&lt;br /&gt;
 calculate_padding() {&lt;br /&gt;
   local fqdn=&amp;quot;$1&amp;quot;&lt;br /&gt;
   local max_fqdn_length=&amp;quot;$2&amp;quot;&lt;br /&gt;
   local padding_length=$((max_fqdn_length - ${#fqdn}))&lt;br /&gt;
   local padding=&amp;quot;&amp;quot; &lt;br /&gt;
 #&lt;br /&gt;
   for ((i=0; i&amp;lt;padding_length; i++)); do&lt;br /&gt;
     padding+=&amp;quot;-&amp;quot;&lt;br /&gt;
   done&lt;br /&gt;
   echo &amp;quot;$padding&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Find the maximum FQDN length&lt;br /&gt;
 max_fqdn_length=0&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       if [ ${#fqdn} -gt $max_fqdn_length ]; then&lt;br /&gt;
         max_fqdn_length=${#fqdn}&lt;br /&gt;
       entry_count=$((entry_count + 1)) # Increment counter&lt;br /&gt;
       fi&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 #&lt;br /&gt;
 # Loop through and print the entries&lt;br /&gt;
 for file in &amp;quot;$DNSMASQ_DIR&amp;quot;*; do&lt;br /&gt;
   if [ -f &amp;quot;$file&amp;quot; ]; then&lt;br /&gt;
     if grep -q &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot;; then&lt;br /&gt;
       fqdn=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $2}&#039;)&lt;br /&gt;
       ip=$(grep &amp;quot;address=&amp;quot; &amp;quot;$file&amp;quot; | awk -F&amp;quot;/&amp;quot; &#039;{print $3}&#039;)&lt;br /&gt;
       padding=$(calculate_padding &amp;quot;$fqdn&amp;quot; &amp;quot;$max_fqdn_length&amp;quot;)&lt;br /&gt;
       echo &amp;quot;-- $fqdn$padding ------------ $ip&amp;quot;&lt;br /&gt;
       echo &amp;quot; &amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
# Print the total count&lt;br /&gt;
echo &amp;quot; &amp;quot;&lt;br /&gt;
echo &amp;quot;Total DNS entries: $entry_count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
==Delete a Record==&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
 !/bin/bash&lt;br /&gt;
 #&lt;br /&gt;
 # Script to delete a DNS record from dnsmasq configuration files.&lt;br /&gt;
 #&lt;br /&gt;
 # Function to prompt for confirmation&lt;br /&gt;
 confirm_delete() {&lt;br /&gt;
   read -p &amp;quot;Are you sure you want to delete $1? (y/n): &amp;quot; choice&lt;br /&gt;
   if [[ &amp;quot;$choice&amp;quot; =~ ^[yY]$ ]]; then&lt;br /&gt;
     return 0&lt;br /&gt;
   elif [[ &amp;quot;$choice&amp;quot; =~ ^[nN]$ ]]; then&lt;br /&gt;
     return 1&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Invalid input. Deletion cancelled.&amp;quot;&lt;br /&gt;
     return 1&lt;br /&gt;
   fi&lt;br /&gt;
 }&lt;br /&gt;
 #&lt;br /&gt;
 # Check if a hostname is provided&lt;br /&gt;
 if [ -z &amp;quot;$1&amp;quot; ]; then&lt;br /&gt;
   echo &amp;quot;Usage: $0 &amp;lt;hostname&amp;gt;&amp;quot;&lt;br /&gt;
   exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 HOSTNAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
 FILENAME=&amp;quot;/etc/dnsmasq.d/$HOSTNAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Check if the file exists with the exact hostname&lt;br /&gt;
 if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
   # If not, try appending .seaoffate.local&lt;br /&gt;
   FILENAME=&amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
   if [ ! -f &amp;quot;$FILENAME&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;Error: DNS record for $HOSTNAME or ${HOSTNAME}.seaoffate.local not fo&amp;gt;&lt;br /&gt;
     exit 1&lt;br /&gt;
   fi&lt;br /&gt;
 fi&lt;br /&gt;
 # Display the record&lt;br /&gt;
 #echo &amp;quot;Record to delete:&amp;quot;&lt;br /&gt;
 cat &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for confirmation&lt;br /&gt;
 #echo &amp;quot;DEBUG: Calling confirm_delete with: $HOSTNAME&amp;quot;&lt;br /&gt;
 confirm_delete &amp;quot;$HOSTNAME&amp;quot;&lt;br /&gt;
 CONFIRM_RESULT=$?&lt;br /&gt;
 #echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
 #&lt;br /&gt;
 if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
     echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
     exit 0&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Prompt for second confirmation only if the first was yes, and the filename en&amp;gt;&lt;br /&gt;
 if [ &amp;quot;${FILENAME}&amp;quot; == &amp;quot;/etc/dnsmasq.d/${HOSTNAME}.seaoffate.local&amp;quot; ]; then&lt;br /&gt;
 #    echo &amp;quot;DEBUG: Filename ends with .seaoffate.local, calling confirm_delete w&amp;gt;&lt;br /&gt;
     confirm_delete &amp;quot;${HOSTNAME}.seaoffate.local&amp;quot;&lt;br /&gt;
     CONFIRM_RESULT=$?&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_delete returned: $CONFIRM_RESULT&amp;quot;&lt;br /&gt;
     if [ &amp;quot;$CONFIRM_RESULT&amp;quot; -ne 0 ]; then&lt;br /&gt;
         echo &amp;quot;DEBUG: confirm_result was not zero&amp;quot;&lt;br /&gt;
         echo &amp;quot;Deletion cancelled.&amp;quot;&lt;br /&gt;
         exit 0&lt;br /&gt;
     fi&lt;br /&gt;
 #    echo &amp;quot;DEBUG: confirm_result was zero&amp;quot;&lt;br /&gt;
 fi&lt;br /&gt;
 #&lt;br /&gt;
 # Delete the file&lt;br /&gt;
 rm &amp;quot;$FILENAME&amp;quot;&lt;br /&gt;
 if [ $? -eq 0 ]; then&lt;br /&gt;
   echo &amp;quot;DNS record for $HOSTNAME deleted successfully.&amp;quot;&lt;br /&gt;
   # Restart dnsmasq&lt;br /&gt;
   systemctl restart dnsmasq&lt;br /&gt;
   if [ $? -eq 0 ]; then&lt;br /&gt;
     echo &amp;quot;dnsmasq restarted.&amp;quot;&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;Error: Failed to restart dnsmasq.&amp;quot;&lt;br /&gt;
   fi&lt;br /&gt;
 else&lt;br /&gt;
   echo &amp;quot;Error: Failed to delete DNS record for $HOSTNAME.&amp;quot;&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=223</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=223"/>
		<updated>2025-03-15T01:36:48Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Add a Hostname &amp;amp; IP Address to DNSmsaq */&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. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=222</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=222"/>
		<updated>2025-03-15T01:36:31Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of webservers. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=221</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=221"/>
		<updated>2025-03-15T01:35:51Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of webservers. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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;
&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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
&amp;lt;br /&amp;gt;&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=220</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=220"/>
		<updated>2025-03-15T01:34:25Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of webservers. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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;
&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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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;
===[[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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=219</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=219"/>
		<updated>2025-03-15T01:32:40Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Add a Hostname &amp;amp; IP Address to DNSmsaq */&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. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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;
&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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=218</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=218"/>
		<updated>2025-03-15T01:32:12Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of webservers. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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;
&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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=217</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=217"/>
		<updated>2025-03-15T01:31:32Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of webservers. The actual scripts are &#039;&#039;&#039;[[Webserver Setup | here ]]&#039;&#039;&#039;&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;
&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;
Add site to Nginx 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;
&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. Note we will have to do this for a hostname and the purpose as the hostname will not be known here eg run once for photo and once more for plum.&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=216</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=216"/>
		<updated>2025-03-15T01:27:38Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of 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;
&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;
=====[[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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=215</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=215"/>
		<updated>2025-03-15T01:25:57Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* 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 deployment of 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;
&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=214</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=214"/>
		<updated>2025-03-15T01:24:58Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Add a Hostname &amp;amp; IP Address to DNSmsaq */&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;br /&gt;
&lt;br /&gt;
The third thing we will want to do from time to time is to delete a record. Call this with the hostname of the dns entry that is to be removed&lt;br /&gt;
 sudo ./delete_dns_record.sh hostname&lt;br /&gt;
hostname can be either FQDN or just the hostname.&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
	<entry>
		<id>https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=213</id>
		<title>Virtual Machines</title>
		<link rel="alternate" type="text/html" href="https://wiki.seaoffate.net/index.php?title=Virtual_Machines&amp;diff=213"/>
		<updated>2025-03-15T01:23:51Z</updated>

		<summary type="html">&lt;p&gt;Sailor: /* Add a Hostname &amp;amp; IP Address to DNSmsaq */&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&lt;br /&gt;
 sudo ./add_dns_record.sh &amp;lt;hostname&amp;gt; &amp;lt;ip_address&amp;gt;&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. The script can be found here&lt;br /&gt;
&lt;br /&gt;
As a quick check to make sure dns looks right there is a quick list of all dns entries called with &lt;br /&gt;
 sudo ./list_dns_entries.sh&lt;/div&gt;</summary>
		<author><name>Sailor</name></author>
	</entry>
</feed>