-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-redirection
More file actions
30 lines (28 loc) · 725 Bytes
/
3-redirection
File metadata and controls
30 lines (28 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# Installs, configures, and starts the server
apt-get update
apt-get -y install nginx
sudo ufw allow 'Nginx HTTP'
mkdir -p /var/www/html/
sudo chmod -R 755 /var/www
echo 'Hello World!' > /var/www/html/index.html
SERVER_CONFIG=\
"server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files \$uri \$uri/ =404;
}
if (\$request_filename ~ redirect_me){
rewrite ^ https://sketchfab.com/bluepeno/models permanent;
}
}"
bash -c "echo -e '$SERVER_CONFIG' > /etc/nginx/sites-enabled/default"
if [ "$(pgrep -c nginx)" -le 0 ]; then
service nginx start
else
service nginx restart
fi