Add VPS setup scripts for domain configuration
This commit is contained in:
parent
cee7e0f016
commit
255988d3dc
|
|
@ -0,0 +1,38 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script deploys the website to the VPS
|
||||||
|
|
||||||
|
# Set variables
|
||||||
|
REMOTE_USER="root"
|
||||||
|
REMOTE_HOST="boilerhaus.org"
|
||||||
|
REMOTE_DIR="/var/www/boilerhaus.org"
|
||||||
|
LOCAL_DIR="."
|
||||||
|
|
||||||
|
# Create a temporary directory for the website files
|
||||||
|
echo "Creating temporary directory..."
|
||||||
|
mkdir -p ./deploy-temp
|
||||||
|
|
||||||
|
# Copy necessary files to the temporary directory
|
||||||
|
echo "Copying website files..."
|
||||||
|
cp -r index.html css dist ./deploy-temp/
|
||||||
|
|
||||||
|
# Create a tarball of the website files
|
||||||
|
echo "Creating tarball..."
|
||||||
|
tar -czf website.tar.gz -C ./deploy-temp .
|
||||||
|
|
||||||
|
# Upload the tarball to the server
|
||||||
|
echo "Uploading to server..."
|
||||||
|
scp website.tar.gz $REMOTE_USER@$REMOTE_HOST:/tmp/
|
||||||
|
|
||||||
|
# Extract the tarball on the server
|
||||||
|
echo "Extracting files on server..."
|
||||||
|
ssh $REMOTE_USER@$REMOTE_HOST "mkdir -p $REMOTE_DIR && \
|
||||||
|
tar -xzf /tmp/website.tar.gz -C $REMOTE_DIR && \
|
||||||
|
chown -R www-data:www-data $REMOTE_DIR && \
|
||||||
|
rm /tmp/website.tar.gz"
|
||||||
|
|
||||||
|
# Clean up local files
|
||||||
|
echo "Cleaning up..."
|
||||||
|
rm -rf ./deploy-temp website.tar.gz
|
||||||
|
|
||||||
|
echo "Website deployed successfully!"
|
||||||
120
setup-vps.sh
120
setup-vps.sh
|
|
@ -1,107 +1,25 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# This script helps set up your VPS for hosting your website and Nextcloud
|
# This script sets up the VPS with the correct Nginx configuration and deploys the website
|
||||||
|
|
||||||
# Check if we can connect to the VPS
|
echo "=== Setting up VPS for boilerhaus.org ==="
|
||||||
echo "Testing connection to VPS..."
|
echo ""
|
||||||
if ! ssh root@66.179.188.130 "echo 'Connection successful'"; then
|
|
||||||
echo "Failed to connect to VPS. Please check your SSH configuration."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if Nginx is installed
|
# Step 1: Update Nginx configuration
|
||||||
echo "Checking if Nginx is installed..."
|
echo "Step 1: Updating Nginx configuration..."
|
||||||
if ! ssh root@66.179.188.130 "which nginx > /dev/null"; then
|
./update-nginx-config.sh
|
||||||
echo "Nginx is not installed. Installing..."
|
|
||||||
ssh root@66.179.188.130 "apt update && apt install -y nginx"
|
|
||||||
else
|
|
||||||
echo "Nginx is already installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if Certbot is installed
|
# Step 2: Deploy website
|
||||||
echo "Checking if Certbot is installed..."
|
echo ""
|
||||||
if ! ssh root@66.179.188.130 "which certbot > /dev/null"; then
|
echo "Step 2: Deploying website..."
|
||||||
echo "Certbot is not installed. Installing..."
|
./deploy-website.sh
|
||||||
ssh root@66.179.188.130 "apt update && apt install -y certbot python3-certbot-nginx"
|
|
||||||
else
|
|
||||||
echo "Certbot is already installed."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Create directory for the website
|
echo ""
|
||||||
echo "Creating directory for the website..."
|
echo "=== Setup complete! ==="
|
||||||
ssh root@66.179.188.130 "mkdir -p /var/www/boilerhaus.org"
|
echo "Your domains should now be configured as follows:"
|
||||||
|
echo "- boilerhaus.org → Main website"
|
||||||
# Create a temporary Nginx configuration without SSL
|
echo "- bw.boilerhaus.org → Vaultwarden instance"
|
||||||
echo "Creating temporary Nginx configuration..."
|
echo "- cloud.boilerhaus.org → Nextcloud dashboard"
|
||||||
cat > temp-boilerhaus.org.conf << EOF
|
echo "- git.boilerhaus.org → Gitea instance"
|
||||||
server {
|
echo ""
|
||||||
listen 80;
|
echo "Please allow a few minutes for DNS changes to propagate."
|
||||||
listen [::]:80;
|
|
||||||
server_name boilerhaus.org www.boilerhaus.org cloud.boilerhaus.org git.boilerhaus.org;
|
|
||||||
|
|
||||||
root /var/www/boilerhaus.org;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
try_files \$uri \$uri/ =404;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
|
|
||||||
# Upload temporary Nginx configuration
|
|
||||||
echo "Uploading temporary Nginx configuration..."
|
|
||||||
scp temp-boilerhaus.org.conf root@66.179.188.130:/etc/nginx/sites-available/boilerhaus.org
|
|
||||||
|
|
||||||
# Enable the site
|
|
||||||
echo "Enabling the site..."
|
|
||||||
ssh root@66.179.188.130 "ln -sf /etc/nginx/sites-available/boilerhaus.org /etc/nginx/sites-enabled/boilerhaus.org"
|
|
||||||
|
|
||||||
# Restart Nginx with temporary configuration
|
|
||||||
echo "Restarting Nginx with temporary configuration..."
|
|
||||||
ssh root@66.179.188.130 "systemctl restart nginx"
|
|
||||||
|
|
||||||
# Check for existing Nextcloud configuration
|
|
||||||
echo "Checking for existing Nextcloud configuration..."
|
|
||||||
if ssh root@66.179.188.130 "[ -d /var/www/nextcloud ]"; then
|
|
||||||
echo "Nextcloud directory found. Assuming Nextcloud is already installed."
|
|
||||||
|
|
||||||
# Ask if user wants to move Nextcloud to cloud subdomain
|
|
||||||
read -p "Do you want to move Nextcloud to cloud.boilerhaus.org? (y/n): " move_nextcloud
|
|
||||||
if [[ $move_nextcloud == "y" ]]; then
|
|
||||||
echo "Updating Nextcloud configuration..."
|
|
||||||
ssh root@66.179.188.130 "sed -i 's/\"trusted_domains\".*$/\"trusted_domains\" => [\"cloud.boilerhaus.org\"],/' /var/www/nextcloud/config/config.php"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "Nextcloud directory not found. Please install Nextcloud manually after setting up the domains."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for Gitea port
|
|
||||||
echo "Checking if Gitea is running..."
|
|
||||||
if ssh root@66.179.188.130 "netstat -tuln | grep -q ':3000'"; then
|
|
||||||
echo "Gitea appears to be running on port 3000."
|
|
||||||
else
|
|
||||||
echo "Warning: Gitea doesn't seem to be running on the expected port (3000)."
|
|
||||||
echo "Please make sure Gitea is installed and running before proceeding."
|
|
||||||
read -p "Continue anyway? (y/n): " continue_anyway
|
|
||||||
if [[ $continue_anyway != "y" ]]; then
|
|
||||||
echo "Setup aborted. Please install and configure Gitea first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up SSL certificates
|
|
||||||
echo "Setting up SSL certificates..."
|
|
||||||
ssh root@66.179.188.130 "certbot --nginx -d boilerhaus.org -d www.boilerhaus.org -d cloud.boilerhaus.org -d git.boilerhaus.org"
|
|
||||||
|
|
||||||
# Now upload the final configuration with SSL
|
|
||||||
echo "Uploading final Nginx configuration with SSL..."
|
|
||||||
scp boilerhaus.org.conf root@66.179.188.130:/etc/nginx/sites-available/boilerhaus.org
|
|
||||||
|
|
||||||
# Restart Nginx with final configuration
|
|
||||||
echo "Restarting Nginx with final configuration..."
|
|
||||||
ssh root@66.179.188.130 "systemctl restart nginx"
|
|
||||||
|
|
||||||
# Clean up temporary file
|
|
||||||
rm temp-boilerhaus.org.conf
|
|
||||||
|
|
||||||
echo "VPS setup complete!"
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This script updates the Nginx configuration for boilerhaus.org and its subdomains
|
||||||
|
|
||||||
|
# Create backup of existing configuration
|
||||||
|
echo "Creating backup of existing Nginx configuration..."
|
||||||
|
ssh root@boilerhaus.org "cp /etc/nginx/sites-available/boilerhaus.org.conf /etc/nginx/sites-available/boilerhaus.org.conf.bak"
|
||||||
|
|
||||||
|
# Create updated configuration file
|
||||||
|
cat > boilerhaus.org.conf.new << 'EOL'
|
||||||
|
# Main website configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name boilerhaus.org www.boilerhaus.org;
|
||||||
|
|
||||||
|
root /var/www/boilerhaus.org;
|
||||||
|
index index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Managed by Certbot
|
||||||
|
# This section will be updated by Certbot automatically
|
||||||
|
}
|
||||||
|
|
||||||
|
# Nextcloud configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name cloud.boilerhaus.org;
|
||||||
|
|
||||||
|
# Proxy to Nextcloud
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:8080;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Managed by Certbot
|
||||||
|
# This section will be updated by Certbot automatically
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gitea configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name git.boilerhaus.org;
|
||||||
|
|
||||||
|
# Proxy to Gitea
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:3000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Managed by Certbot
|
||||||
|
# This section will be updated by Certbot automatically
|
||||||
|
}
|
||||||
|
|
||||||
|
# Vaultwarden configuration
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
listen [::]:80;
|
||||||
|
server_name bw.boilerhaus.org;
|
||||||
|
|
||||||
|
# Proxy to Vaultwarden
|
||||||
|
location / {
|
||||||
|
proxy_pass http://localhost:8000;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Managed by Certbot
|
||||||
|
# This section will be updated by Certbot automatically
|
||||||
|
}
|
||||||
|
|
||||||
|
# SSL configurations will be added by Certbot automatically
|
||||||
|
EOL
|
||||||
|
|
||||||
|
# Upload the new configuration
|
||||||
|
echo "Uploading new configuration..."
|
||||||
|
scp boilerhaus.org.conf.new root@boilerhaus.org:/etc/nginx/sites-available/boilerhaus.org.conf
|
||||||
|
|
||||||
|
# Test Nginx configuration
|
||||||
|
echo "Testing Nginx configuration..."
|
||||||
|
ssh root@boilerhaus.org "nginx -t"
|
||||||
|
|
||||||
|
# If the test is successful, reload Nginx
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Reloading Nginx..."
|
||||||
|
ssh root@boilerhaus.org "systemctl reload nginx"
|
||||||
|
echo "Configuration updated successfully!"
|
||||||
|
else
|
||||||
|
echo "Nginx configuration test failed. Restoring backup..."
|
||||||
|
ssh root@boilerhaus.org "cp /etc/nginx/sites-available/boilerhaus.org.conf.bak /etc/nginx/sites-available/boilerhaus.org.conf"
|
||||||
|
echo "Backup restored. Please check the configuration and try again."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run Certbot to ensure SSL certificates are set up for all domains
|
||||||
|
echo "Running Certbot to ensure SSL certificates are set up..."
|
||||||
|
ssh root@boilerhaus.org "certbot --nginx -d boilerhaus.org -d www.boilerhaus.org -d cloud.boilerhaus.org -d git.boilerhaus.org -d bw.boilerhaus.org --non-interactive --agree-tos --email admin@boilerhaus.org"
|
||||||
|
|
||||||
|
echo "Done!"
|
||||||
Loading…
Reference in New Issue