Skip to content

Commit d27be47

Browse files
committed
updated nginx setup scripts and configs + enable stt path by default
1 parent b298e77 commit d27be47

File tree

4 files changed

+78
-71
lines changed

4 files changed

+78
-71
lines changed

sepia-custom-bundle-folder/nginx/sites-available/sepia-fw-http.conf

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
##
22
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
3+
#
4+
# To make this SEPIA config work please replace [my-sepia-path]
5+
# with your own value. You can use the setup-nginx.sh.
36
##
47

58
# SEPIA WebSockets
@@ -10,19 +13,13 @@ map $http_upgrade $connection_upgrade {
1013

1114
# SEPIA HTTP
1215
server {
13-
listen 20726;
14-
server_name localhost;
16+
listen 20726;
17+
listen [::]:20726;
18+
# catch all domains:
19+
server_name _;
1520

16-
location / {
17-
root html;
18-
index index.html index.htm;
19-
}
20-
21-
#error_page 404 /404.html;
22-
error_page 500 502 503 504 /50x.html;
23-
location = /50x.html {
24-
root html;
25-
}
21+
root [my-sepia-path]/nginx/www;
22+
index index.html index.htm;
2623

2724
location /sepia/assist/ {
2825
proxy_pass http://localhost:20721/;
@@ -41,18 +38,17 @@ server {
4138
proxy_read_timeout 14400;
4239
}
4340

44-
# If you want to access the STT server from here uncomment this and set correct URL:
45-
#
46-
# location /sepia/stt/ {
47-
# proxy_pass http://localhost:20741/;
48-
# }
49-
# location /sepia/stt/socket {
50-
# proxy_pass http://localhost:20741/socket;
51-
# proxy_http_version 1.1;
52-
# proxy_set_header Upgrade $http_upgrade;
53-
# proxy_set_header Connection $connection_upgrade;
54-
# proxy_read_timeout 30s;
55-
# }
41+
# If you're STT server is running on a different machine set the correct URL here or comment out the block:
42+
location /sepia/stt/ {
43+
proxy_pass http://localhost:20741/;
44+
}
45+
location /sepia/stt/socket {
46+
proxy_pass http://localhost:20741/socket;
47+
proxy_http_version 1.1;
48+
proxy_set_header Upgrade $http_upgrade;
49+
proxy_set_header Connection $connection_upgrade;
50+
proxy_read_timeout 30s;
51+
}
5652

5753
# If you want to access a Mary-TTS compatible API directly you can use this:
5854
# NOTE: Your TTS server will not be secured this way, so use this only in local network!

sepia-custom-bundle-folder/nginx/sites-available/sepia-fw-https-self-signed.conf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ server {
1717
listen 20726 ssl http2;
1818
listen [::]:20726 ssl http2;
1919
listen 20727;
20+
listen [::]:20727;
2021
# domain to listen to
21-
server_name [my-hostname-or-ip];
22+
server_name localhost [my-hostname-or-ip];
2223

23-
#root /var/www/html/sepia;
24+
root [my-sepia-path]/nginx/www;
2425
index index.html index.htm;
2526

2627
location /sepia/assist/ {
@@ -40,18 +41,17 @@ server {
4041
proxy_read_timeout 14400;
4142
}
4243

43-
# If you want to access the STT server from here uncomment this and set correct URL:
44-
#
45-
# location /sepia/stt/ {
46-
# proxy_pass http://localhost:20741/;
47-
# }
48-
# location /sepia/stt/socket {
49-
# proxy_pass http://localhost:20741/socket;
50-
# proxy_http_version 1.1;
51-
# proxy_set_header Upgrade $http_upgrade;
52-
# proxy_set_header Connection $connection_upgrade;
53-
# proxy_read_timeout 30s;
54-
# }
44+
# If you're STT server is running on a different machine set the correct URL here or comment out the block:
45+
location /sepia/stt/ {
46+
proxy_pass http://localhost:20741/;
47+
}
48+
location /sepia/stt/socket {
49+
proxy_pass http://localhost:20741/socket;
50+
proxy_http_version 1.1;
51+
proxy_set_header Upgrade $http_upgrade;
52+
proxy_set_header Connection $connection_upgrade;
53+
proxy_read_timeout 30s;
54+
}
5555

5656
# If you want to access a Mary-TTS compatible API directly you can use this:
5757
# NOTE: Your TTS server will not be secured this way, so use this only in local network!

sepia-custom-bundle-folder/nginx/sites-available/sepia-fw-https.conf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ server {
1919
# domain to listen to
2020
server_name [my-example-com];
2121

22-
#root /var/www/html/sepia;
22+
root [my-sepia-path]/nginx/www;
2323
index index.html index.htm;
2424

2525
location /sepia/assist/ {
@@ -39,18 +39,17 @@ server {
3939
proxy_read_timeout 14400;
4040
}
4141

42-
# If you want to access the STT server from here uncomment this and set correct URL:
43-
#
44-
# location /sepia/stt/ {
45-
# proxy_pass http://localhost:20741/;
46-
# }
47-
# location /sepia/stt/socket {
48-
# proxy_pass http://localhost:20741/socket;
49-
# proxy_http_version 1.1;
50-
# proxy_set_header Upgrade $http_upgrade;
51-
# proxy_set_header Connection $connection_upgrade;
52-
# proxy_read_timeout 30s;
53-
# }
42+
# If you're STT server is running on a different machine set the correct URL here or comment out the block:
43+
location /sepia/stt/ {
44+
proxy_pass http://localhost:20741/;
45+
}
46+
location /sepia/stt/socket {
47+
proxy_pass http://localhost:20741/socket;
48+
proxy_http_version 1.1;
49+
proxy_set_header Upgrade $http_upgrade;
50+
proxy_set_header Connection $connection_upgrade;
51+
proxy_read_timeout 30s;
52+
}
5453

5554
# If you want to access a Mary-TTS compatible API directly you can use this:
5655
# NOTE: Your TTS server will not be secured this way, so use this only in local network!

sepia-custom-bundle-folder/setup-nginx.sh

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,27 @@ SCRIPT_PATH="$(realpath "$BASH_SOURCE")"
66
SEPIA_FOLDER="$(dirname "$SCRIPT_PATH")"
77
cd "$SEPIA_FOLDER"
88
#
9+
# get IP
10+
net_interface=""
11+
get_ip() {
12+
local ip_adr=""
13+
if [ -x "$(command -v route)" ]; then
14+
net_interface="$(route | grep '^default' | grep -o '[^ ]*$')"
15+
fi
16+
if [ -z "$net_interface" ]; then
17+
net_interface="eth0|wlan0"
18+
fi
19+
if [ -x "$(command -v ip)" ]; then
20+
ip_adr=$(ip a | grep -E "$net_interface" | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1)
21+
elif [ -x "$(command -v ifconfig)" ]; then
22+
ip_adr=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1)
23+
fi
24+
if [ -z "$ip_adr" ]; then
25+
ip_adr="[IP]"
26+
fi
27+
echo "$ip_adr"
28+
}
29+
#
930
echo ""
1031
echo "Welcome to NGINX setup for SEPIA."
1132
echo ""
@@ -39,21 +60,17 @@ while true; do
3960
then
4061
echo "Copying $SEPIA_FOLDER/nginx/sites-available/sepia-fw-http.conf to /etc/nginx/sites-enabled/ ..."
4162
cd $SEPIA_FOLDER/nginx/sites-available
42-
sudo cp sepia-fw-http.conf /etc/nginx/sites-enabled/
63+
cp sepia-fw-http.conf sepia-fw-http-latest.conf
64+
#sed -i -e 's|\[my-hostname-or-ip\]|'"${my_hostname}"'|g' sepia-fw-http-${my_hostname}.conf
65+
sed -i -e 's|\[my-sepia-path\]|'"$SEPIA_FOLDER"'|g' sepia-fw-http-latest.conf
66+
sudo cp sepia-fw-http-latest.conf /etc/nginx/sites-enabled/sepia-fw-http.conf
4367

4468
echo "Restarting NGINX to load new config ..."
4569
sudo nginx -t
4670
sudo nginx -s reload
4771

4872
echo ""
49-
ip_adr=""
50-
if [ -x "$(command -v ip)" ]; then
51-
# old: ifconfig
52-
ip_adr=$(ip a | grep -E 'eth0|wlan0' | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1)
53-
fi
54-
if [ -z "$ip_adr" ]; then
55-
ip_adr="[IP]"
56-
fi
73+
ip_adr="$get_ip"
5774
echo "------------------------"
5875
echo "DONE."
5976
echo "You should be able to reach the server at: http://$ip_adr:20726 or http://$(hostname -s).local:20726"
@@ -114,16 +131,8 @@ while true; do
114131
echo "Please confirm your [detected] hostname and IP address by pressing RETURN or enter new ones."
115132
read -p "Hostname [$(hostname -s).local]: " my_hostname
116133
my_hostname=${my_hostname:-$(hostname -s).local}
117-
ip_adr=""
118-
if [ -x "$(command -v ip)" ]; then
119-
ip_adr=$(ip a | grep -E 'eth0|wlan0' | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1)
120-
elif [ -x "$(command -v ifconfig)" ]; then
121-
ip_adr=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p' | head -1)
122-
fi
123-
if [ -z "$ip_adr" ]; then
124-
ip_adr="[IP]"
125-
fi
126-
read -p "IP address [$ip_adr]: " my_ip_adr
134+
ip_adr="$get_ip"
135+
read -p "IP address (interf.: $net_interface) [$ip_adr]: " my_ip_adr
127136
my_ip_adr=${my_ip_adr:-$ip_adr}
128137
echo ""
129138
echo "The 'openssl' tool will create new certificates now with $my_hostname as 'common name' and add"
@@ -134,7 +143,10 @@ while true; do
134143
mkdir -p self-signed-ssl
135144
openssl req -nodes -new -x509 -days 3650 -newkey rsa:2048 -keyout self-signed-ssl/key.pem -out self-signed-ssl/certificate.pem \
136145
-subj "/CN=$my_hostname" \
137-
-addext "subjectAltName=DNS:$my_hostname,DNS:$my_ip_adr,DNS:localhost"
146+
-addext "subjectAltName=DNS:$my_hostname,DNS:$my_ip_adr,DNS:localhost" \
147+
-addext "basicConstraints=CA:TRUE" \
148+
-addext "keyUsage=digitalSignature,nonRepudiation,keyEncipherment,dataEncipherment" \
149+
-addext "extendedKeyUsage=serverAuth"
138150
# subj options: "/C=DE/ST=NRW/L=Essen/O=SEPIA OA Framework/OU=DEV/CN=yourdomain.com"
139151
openssl x509 -text -in self-signed-ssl/certificate.pem -noout | grep "Subject:"
140152
openssl x509 -text -in self-signed-ssl/certificate.pem -noout | grep "DNS:"

0 commit comments

Comments
 (0)