-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path0-custom_http_response_header
executable file
·36 lines (35 loc) · 1.21 KB
/
0-custom_http_response_header
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
31
32
33
34
35
36
#!/usr/bin/env bash
# Install and setup nginx with custom headers
# shellcheck disable=SC2154
function install_and_configure_nginx(){
sudo apt-get update
sudo apt-get -y install nginx
sudo chown -R "$USER":"$USER" /var/www/html/
echo 'Hello World!' > /var/www/html/index.html
sudo chown -R "$USER":"$USER" /etc/nginx/sites-available/
server_conf="server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
add_header X-Served-By \$hostname;
location / {
try_files \$uri \$uri/ =404;
}
location /redirect_me {
rewrite ^ https://youtube.com/watch?v=QH2-TGUlwu4 permanent;
}
error_page 404 /404.html;
location = /404.html {
internal;
}
}"
echo -e "$server_conf" > /etc/nginx/sites-available/default
if [[ $(pgrep nginx) ]]; then
sudo nginx -s reload
else
sudo service nginx start
fi
}
install_and_configure_nginx;