-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path10-install_nginx.sh
executable file
·94 lines (73 loc) · 2.46 KB
/
10-install_nginx.sh
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Exit script on any error
set -e
# Update and upgrade the system
echo "Updating system..."
sudo apt update && sudo apt upgrade -y
# Install Nginx
echo "Installing Nginx..."
sudo apt install -y nginx
# Create directory for the Alfresco Content App
echo "Creating directory for Alfresco Content App..."
sudo mkdir -p /var/www/alfresco-content-app
sudo cp -r /home/ubuntu/alfresco-content-app/dist/content-ce/* /var/www/alfresco-content-app
echo "Creating nginx systemd service file..."
cat <<EOL | sudo tee /etc/systemd/system/nginx.service
[Unit]
Description=A high performance web server and a reverse proxy server
Documentation=man:nginx(8)
After=network.target remote-fs.target nss-lookup.target solr.service
Requires=solr.service
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;'
ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;'
ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOL
echo "Reloading systemd daemon..."
sudo systemctl daemon-reload
echo "Enabling nginx service to start on boot..."
sudo systemctl enable nginx
# Configure Nginx to serve the Alfresco Content App
echo "Configuring Nginx..."
cat <<EOL | sudo tee /etc/nginx/sites-available/alfresco-content-app
server {
listen 80;
server_name localhost;
client_max_body_size 0;
set \$allowOriginSite *;
proxy_pass_request_headers on;
proxy_pass_header Set-Cookie;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host \$host:\$server_port;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass_header Set-Cookie;
root /var/www/alfresco-content-app;
index index.html;
location / {
try_files \$uri \$uri/ /index.html;
}
location /alfresco/ {
proxy_pass http://localhost:8080;
}
location /share/ {
proxy_pass http://localhost:8080;
}
}
EOL
# Enable the new Nginx configuration
echo "Enabling Nginx configuration..."
sudo ln -s /etc/nginx/sites-available/alfresco-content-app /etc/nginx/sites-enabled/
sudo nginx -t
# sudo systemctl restart nginx
# sudo systemctl stop nginx
# Instructions to transfer the built files
echo "Nginx setup complete."