Skip to content

Commit 058f3ee

Browse files
author
Tim Pouyer
committed
add reverse proxy for *.stackinabox.io addresses
1 parent babd39a commit 058f3ee

File tree

2 files changed

+124
-4
lines changed

2 files changed

+124
-4
lines changed

scripts/stackinabox/post-config.sh

Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,135 @@ Host *
117117
UserKnownHostsFile=/dev/null
118118
EOF
119119

120+
# change "Listen 80' to 'Listen 8888' in /etc/apache2/ports.conf
121+
sudo sed -i 's/Listen 80/Listen 8888/g' /etc/apache2/ports.conf
122+
123+
# change 'VirtualHost *:80' to 'VirtualHost *:8888' in /etc/apache2/sites-enabled/horizon.conf
124+
sudo sed -i 's/:80/:8888/g' /etc/apache2/sites-enabled/horizon.conf
125+
126+
sudo systemctl reload apache2
127+
128+
# install nginx
129+
sudo apt-get install -qqy nginx
130+
131+
# disable the default vhost site
132+
sudo rm -f /etc/nginx/sites-enabled/default
133+
134+
# update /etc/nginx/nginx.conf
135+
# change 'sendfile on;' to 'sendfile off;'
136+
sudo sed -i 's/sendfile on;/sendfile off;/g' /etc/nginx/nginx.conf
137+
138+
# add 'underscores_in_headers on;'
139+
sudo sed -i 's/# server_tokens off;/underscores_in_headers on;/g' /etc/nginx/nginx.conf
140+
141+
# setup openstack.stackinabox.io forwarding
142+
sudo bash -c 'cat > /etc/nginx/sites-available/openstack.conf' <<'EOF'
143+
server {
144+
server_name openstack.stackinabox.io 192.168.27.100;
145+
146+
gzip_types text/plain text/css application/json application/x-javascript
147+
text/xml application/xml application/xml+rss text/javascript;
148+
149+
location / {
150+
151+
proxy_redirect off;
152+
proxy_pass http://192.168.27.100:8888/;
153+
proxy_set_header Host $host:$server_port;
154+
proxy_set_header X-Real-IP $remote_addr;
155+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
156+
proxy_set_header X-Forwarded-Proto $scheme;
157+
}
158+
}
159+
EOF
160+
sudo ln -s /etc/nginx/sites-available/openstack.conf /etc/nginx/sites-enabled/openstack.conf
161+
162+
# setup ucd.stackinabox.io forwarding
163+
sudo bash -c 'cat > /etc/nginx/sites-available/ucd.conf' <<'EOF'
164+
server {
165+
server_name ucd.stackinabox.io;
166+
167+
gzip_types text/plain text/css application/json application/x-javascript
168+
text/xml application/xml application/xml+rss text/javascript;
169+
170+
location / {
171+
172+
proxy_redirect off;
173+
proxy_pass http://ucd.stackinabox.io:8080/;
174+
proxy_set_header Host $host;
175+
proxy_set_header X-Real-IP $remote_addr;
176+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
177+
proxy_set_header X-Forwarded-Proto $scheme;
178+
}
179+
}
180+
EOF
181+
sudo ln -s /etc/nginx/sites-available/ucd.conf /etc/nginx/sites-enabled/ucd.conf
182+
183+
# setup shell.stackinabox.io forwarding
184+
sudo bash -c 'cat > /etc/nginx/sites-available/shell.conf' <<'EOF'
185+
server {
186+
server_name shell.stackinabox.io;
187+
188+
gzip_types text/plain text/css application/json application/x-javascript
189+
text/xml application/xml application/xml+rss text/javascript;
190+
191+
location / {
192+
193+
proxy_redirect off;
194+
proxy_pass http://shell.stackinabox.io:4200/;
195+
proxy_set_header Host $host;
196+
proxy_set_header X-Real-IP $remote_addr;
197+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
198+
proxy_set_header X-Forwarded-Proto $scheme;
199+
}
200+
}
201+
EOF
202+
sudo ln -s /etc/nginx/sites-available/shell.conf /etc/nginx/sites-enabled/shell.conf
203+
204+
# setup designer.stackinabox.io forwarding
205+
sudo bash -c 'cat > /etc/nginx/sites-available/designer.conf' <<'EOF'
206+
server {
207+
server_name designer.stackinabox.io;
208+
209+
gzip_types text/plain text/css application/json application/x-javascript
210+
text/xml application/xml application/xml+rss text/javascript;
211+
212+
location / {
213+
return 302 /landscaper/;
214+
}
215+
216+
location /landscaper/ {
217+
218+
proxy_redirect off;
219+
proxy_pass http://designer.stackinabox.io:9080/landscaper/;
220+
proxy_set_header Host $host;
221+
proxy_set_header X-Real-IP $remote_addr;
222+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
223+
proxy_set_header X-Forwarded-Proto $scheme;
224+
}
225+
}
226+
EOF
227+
sudo ln -s /etc/nginx/sites-available/designer.conf /etc/nginx/sites-enabled/designer.conf
228+
229+
# reload nginx
230+
sudo systemctl reload nginx
231+
120232
cat << 'EOF'
233+
121234
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
122-
This is your host IP address: 192.168.27.100
123-
Horizon is now available at http://192.168.27.100/dashboard
124-
Keystone is serving at http://192.168.27.100/identity
235+
236+
Horizon is now available at http://openstack.stackinabox.io
237+
Keystone is serving at http://192.168.27.100:8888/identity/v3
125238
The default users are: admin and demo
126239
The password: labstack
127240
Key pair is at /home/vagrant/demo_key.priv
128241
129-
++++++ Login to this VM using:
242+
++++++ Access the console from your shell:
130243
ssh demo@192.168.27.100
131244
password: labstack
132245
246+
++++++ Access the console from your web browser at:
247+
http://shell.stackinabox.io
248+
username: demo
249+
password: labstack
250+
133251
EOF

vagrant/Vagrantfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ENV["LANG"] = "C.UTF-8"
77
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
88
VAGRANTFILE_API_VERSION = "2"
99

10+
Vagrant.require_version ">= 1.9.1"
11+
1012
vagrant_dir = File.expand_path(File.dirname(__FILE__))
1113
personalization = File.expand_path(File.join(vagrant_dir, "Personalization"), __FILE__)
1214
if not File.exist?(personalization)

0 commit comments

Comments
 (0)