blob: f29c7ea2cb3658a460f1b7bfcc782e082c2c0875 [file] [log] [blame]
Sean Daguee263c822014-12-05 14:25:28 -05001#!/bin/bash
2#
zhang-hared98a5d02013-06-21 18:18:02 +08003# lib/apache
4# Functions to control configuration and operation of apache web server
5
6# Dependencies:
Adam Spiers6a5aa7c2013-10-24 11:27:02 +01007#
8# - ``functions`` file
Dean Troyerd8864fe2014-02-17 11:00:42 -06009# - ``STACK_USER`` must be defined
10#
Stephan Renatuse578eff2013-11-19 13:31:04 +010011# lib/apache exports the following functions:
12#
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010013# - install_apache_wsgi
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +000014# - apache_site_config_for
Adam Spiers6a5aa7c2013-10-24 11:27:02 +010015# - enable_apache_site
16# - disable_apache_site
17# - start_apache_server
18# - stop_apache_server
19# - restart_apache_server
zhang-hared98a5d02013-06-21 18:18:02 +080020
21# Save trace setting
Ian Wienand523f4882015-10-13 11:03:03 +110022_XTRACE_LIB_APACHE=$(set +o | grep xtrace)
zhang-hared98a5d02013-06-21 18:18:02 +080023set +o xtrace
24
25# Allow overriding the default Apache user and group, default to
26# current user and his default group.
Stephan Renatuse578eff2013-11-19 13:31:04 +010027APACHE_USER=${APACHE_USER:-$STACK_USER}
zhang-hared98a5d02013-06-21 18:18:02 +080028APACHE_GROUP=${APACHE_GROUP:-$(id -gn $APACHE_USER)}
29
30
31# Set up apache name and configuration directory
Clark Boylancfb9f052016-11-29 10:43:05 -080032# Note that APACHE_CONF_DIR is really more accurately apache's vhost
33# configuration dir but we can't just change this because public interfaces.
zhang-hared98a5d02013-06-21 18:18:02 +080034if is_ubuntu; then
35 APACHE_NAME=apache2
Dean Troyer444a8d52014-06-06 16:36:52 -050036 APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/sites-available}
Clark Boylancfb9f052016-11-29 10:43:05 -080037 APACHE_SETTINGS_DIR=${APACHE_SETTINGS_DIR:-/etc/$APACHE_NAME/conf-enabled}
zhang-hared98a5d02013-06-21 18:18:02 +080038elif is_fedora; then
39 APACHE_NAME=httpd
Dean Troyer444a8d52014-06-06 16:36:52 -050040 APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/conf.d}
Clark Boylancfb9f052016-11-29 10:43:05 -080041 APACHE_SETTINGS_DIR=${APACHE_SETTINGS_DIR:-/etc/$APACHE_NAME/conf.d}
zhang-hared98a5d02013-06-21 18:18:02 +080042elif is_suse; then
43 APACHE_NAME=apache2
Dean Troyer444a8d52014-06-06 16:36:52 -050044 APACHE_CONF_DIR=${APACHE_CONF_DIR:-/etc/$APACHE_NAME/vhosts.d}
Clark Boylancfb9f052016-11-29 10:43:05 -080045 APACHE_SETTINGS_DIR=${APACHE_SETTINGS_DIR:-/etc/$APACHE_NAME/conf.d}
zhang-hared98a5d02013-06-21 18:18:02 +080046fi
Clark Boylan66ce5c22016-10-05 12:11:05 -070047APACHE_LOG_DIR="/var/log/${APACHE_NAME}"
zhang-hared98a5d02013-06-21 18:18:02 +080048
49# Functions
50# ---------
Gregory Haynes4b49e402016-08-31 18:19:51 -070051
52# Enable apache mod and restart apache if it isn't already enabled.
53function enable_apache_mod {
54 local mod=$1
55 # Apache installation, because we mark it NOPRIME
Clark Boylan35649ae2017-05-27 17:52:55 -070056 if is_ubuntu; then
57 # Skip mod_version as it is not a valid mod to enable
58 # on debuntu, instead it is built in.
59 if [[ "$mod" != "version" ]] && ! a2query -m $mod ; then
60 sudo a2enmod $mod
61 restart_apache_server
62 fi
63 elif is_suse; then
64 if ! a2enmod -q $mod ; then
Gregory Haynes4b49e402016-08-31 18:19:51 -070065 sudo a2enmod $mod
66 restart_apache_server
67 fi
68 elif is_fedora; then
69 # pass
70 true
71 else
72 exit_distro_not_supported "apache enable mod"
73 fi
74}
75
Sean Dague604e5982017-04-13 13:28:12 -040076# NOTE(sdague): Install uwsgi including apache module, we need to get
77# to 2.0.6+ to get a working mod_proxy_uwsgi. We can probably build a
78# check for that and do it differently for different platforms.
79function install_apache_uwsgi {
80 local apxs="apxs2"
81 if is_fedora; then
82 apxs="apxs"
83 fi
84
Ian Wienand2d903562018-05-03 10:51:30 +100085 if is_ubuntu; then
Dr. Jens Harbott34800932020-02-13 09:38:35 +000086 local pkg_list="uwsgi uwsgi-plugin-python3 libapache2-mod-proxy-uwsgi"
Dr. Jens Harbott34800932020-02-13 09:38:35 +000087 install_package ${pkg_list}
Ian Wienand343e3512022-02-03 11:19:08 +110088 # NOTE(ianw) 2022-02-03 : Fedora 35 needs to skip this and fall
89 # into the install-from-source because the upstream packages
90 # didn't fix Python 3.10 compatibility before release. Should be
91 # fixed in uwsgi 4.9.0; can remove this when packages available
92 # or we drop this release
93 elif is_fedora && ! is_openeuler && ! [[ $DISTRO =~ f35 ]]; then
Ian Wienand2d903562018-05-03 10:51:30 +100094 # Note httpd comes with mod_proxy_uwsgi and it is loaded by
95 # default; the mod_proxy_uwsgi package actually conflicts now.
96 # See:
97 # https://bugzilla.redhat.com/show_bug.cgi?id=1574335
98 #
99 # Thus there is nothing else to do after this install
100 install_package uwsgi \
101 uwsgi-plugin-python3
Andreas Jaeger10c3ffd2020-06-15 10:03:42 +0200102 elif [[ $os_VENDOR =~ openSUSE ]]; then
103 install_package uwsgi \
104 uwsgi-python3 \
105 apache2-mod_uwsgi
Ian Wienand2d903562018-05-03 10:51:30 +1000106 else
Federico Ressic2c2b6b2020-06-15 12:48:38 +0200107 # Compile uwsgi from source.
Ian Wienand2d903562018-05-03 10:51:30 +1000108 local dir
109 dir=$(mktemp -d)
110 pushd $dir
111 pip_install uwsgi
112 pip download uwsgi -c $REQUIREMENTS_DIR/upper-constraints.txt
113 local uwsgi
114 uwsgi=$(ls uwsgi*)
115 tar xvf $uwsgi
116 cd uwsgi*/apache2
117 sudo $apxs -i -c mod_proxy_uwsgi.c
118 popd
119 # delete the temp directory
120 sudo rm -rf $dir
Ian Wienand2d903562018-05-03 10:51:30 +1000121 fi
Sean Dague604e5982017-04-13 13:28:12 -0400122
Clark Boylan35649ae2017-05-27 17:52:55 -0700123 if is_ubuntu || is_suse ; then
Sean Dague604e5982017-04-13 13:28:12 -0400124 # we've got to enable proxy and proxy_uwsgi for this to work
125 sudo a2enmod proxy
126 sudo a2enmod proxy_uwsgi
127 elif is_fedora; then
128 # redhat is missing a nice way to turn on/off modules
129 echo "LoadModule proxy_uwsgi_module modules/mod_proxy_uwsgi.so" \
130 | sudo tee /etc/httpd/conf.modules.d/02-proxy-uwsgi.conf
131 fi
132 restart_apache_server
133}
134
zhang-hared98a5d02013-06-21 18:18:02 +0800135# install_apache_wsgi() - Install Apache server and wsgi module
Ian Wienandaee18c72014-02-21 15:35:08 +1100136function install_apache_wsgi {
zhang-hared98a5d02013-06-21 18:18:02 +0800137 # Apache installation, because we mark it NOPRIME
138 if is_ubuntu; then
139 # Install apache2, which is NOPRIME'd
Davanum Srinivasafa8a002016-12-19 09:51:01 -0500140 install_package apache2
Jens Harbottd7a82f42020-06-23 10:21:09 +0200141 if is_package_installed libapache2-mod-wsgi; then
142 uninstall_package libapache2-mod-wsgi
Davanum Srinivasafa8a002016-12-19 09:51:01 -0500143 fi
Jens Harbottd7a82f42020-06-23 10:21:09 +0200144 install_package libapache2-mod-wsgi-py3
zhang-hared98a5d02013-06-21 18:18:02 +0800145 elif is_fedora; then
146 sudo rm -f /etc/httpd/conf.d/000-*
Hirotaka Wakabayashi1e265082020-07-02 06:19:21 +0000147 install_package httpd python3-mod_wsgi
Ian Wienand41e6e122017-08-08 15:06:26 +1000148 # For consistency with Ubuntu, switch to the worker mpm, as
Attila Fazekas9fd38e72017-12-11 12:20:25 +0100149 # the default is event
Ian Wienand41e6e122017-08-08 15:06:26 +1000150 sudo sed -i '/mod_mpm_prefork.so/s/^/#/g' /etc/httpd/conf.modules.d/00-mpm.conf
Attila Fazekas9fd38e72017-12-11 12:20:25 +0100151 sudo sed -i '/mod_mpm_event.so/s/^/#/g' /etc/httpd/conf.modules.d/00-mpm.conf
Ian Wienand41e6e122017-08-08 15:06:26 +1000152 sudo sed -i '/mod_mpm_worker.so/s/^#//g' /etc/httpd/conf.modules.d/00-mpm.conf
zhang-hared98a5d02013-06-21 18:18:02 +0800153 elif is_suse; then
154 install_package apache2 apache2-mod_wsgi
155 else
Gregory Haynes4b49e402016-08-31 18:19:51 -0700156 exit_distro_not_supported "apache wsgi installation"
zhang-hared98a5d02013-06-21 18:18:02 +0800157 fi
Gregory Haynes4b49e402016-08-31 18:19:51 -0700158 # WSGI isn't enabled by default, enable it
159 enable_apache_mod wsgi
Morgan Fainbergd074dc72014-06-24 21:33:39 -0700160}
161
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000162# apache_site_config_for() - The filename of the site's configuration file.
163# This function uses the global variables APACHE_NAME and APACHE_CONF_DIR.
164#
Sean Dague8f8b2742017-04-13 09:34:12 -0400165# On Ubuntu 14.04+, the site configuration file must have a .conf suffix for a2ensite and a2dissite to
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000166# recognise it. a2ensite and a2dissite ignore the .conf suffix used as parameter. The default sites'
167# files are 000-default.conf and default-ssl.conf.
168#
Ralf Haferkamp633a1292014-06-16 14:10:05 +0200169# On Fedora and openSUSE, any file in /etc/httpd/conf.d/ whose name ends with .conf is enabled.
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000170#
171# On RHEL and CentOS, things should hopefully work as in Fedora.
172#
173# The table below summarizes what should happen on each distribution:
174# +----------------------+--------------------+--------------------------+--------------------------+
175# | Distribution | File name | Site enabling command | Site disabling command |
176# +----------------------+--------------------+--------------------------+--------------------------+
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000177# | Ubuntu 14.04 | site.conf | a2ensite site | a2dissite site |
178# | Fedora, RHEL, CentOS | site.conf.disabled | mv site.conf{.disabled,} | mv site.conf{,.disabled} |
179# +----------------------+--------------------+--------------------------+--------------------------+
180function apache_site_config_for {
181 local site=$@
182 if is_ubuntu; then
Sean Dague8f8b2742017-04-13 09:34:12 -0400183 # Ubuntu 14.04 - Apache 2.4
184 echo $APACHE_CONF_DIR/${site}.conf
Ralf Haferkamp633a1292014-06-16 14:10:05 +0200185 elif is_fedora || is_suse; then
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000186 # fedora conf.d is only imported if it ends with .conf so this is approx the same
Dean Troyer444a8d52014-06-06 16:36:52 -0500187 local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
Gabriel Assis Bezerraa688bc62014-05-27 20:58:22 +0000188 if [ -f $enabled_site_file ]; then
189 echo ${enabled_site_file}
190 else
191 echo ${enabled_site_file}.disabled
192 fi
193 fi
194}
195
Jamie Lennox54707012013-09-17 12:07:48 +1000196# enable_apache_site() - Enable a particular apache site
Ian Wienandaee18c72014-02-21 15:35:08 +1100197function enable_apache_site {
Jamie Lennox54707012013-09-17 12:07:48 +1000198 local site=$@
Clark Boylan35649ae2017-05-27 17:52:55 -0700199 # Many of our sites use mod version. Just enable it.
200 enable_apache_mod version
Jamie Lennox54707012013-09-17 12:07:48 +1000201 if is_ubuntu; then
202 sudo a2ensite ${site}
Ralf Haferkamp633a1292014-06-16 14:10:05 +0200203 elif is_fedora || is_suse; then
Dean Troyer444a8d52014-06-06 16:36:52 -0500204 local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
205 # Do nothing if site already enabled or no site config exists
206 if [[ -f ${enabled_site_file}.disabled ]] && [[ ! -f ${enabled_site_file} ]]; then
207 sudo mv ${enabled_site_file}.disabled ${enabled_site_file}
208 fi
Jamie Lennox54707012013-09-17 12:07:48 +1000209 fi
210}
211
212# disable_apache_site() - Disable a particular apache site
Ian Wienandaee18c72014-02-21 15:35:08 +1100213function disable_apache_site {
Jamie Lennox54707012013-09-17 12:07:48 +1000214 local site=$@
215 if is_ubuntu; then
Chris Dent2fcdaac2017-04-18 16:54:12 +0100216 sudo a2dissite ${site} || true
Ralf Haferkamp633a1292014-06-16 14:10:05 +0200217 elif is_fedora || is_suse; then
Dean Troyer444a8d52014-06-06 16:36:52 -0500218 local enabled_site_file="$APACHE_CONF_DIR/${site}.conf"
219 # Do nothing if no site config exists
220 if [[ -f ${enabled_site_file} ]]; then
221 sudo mv ${enabled_site_file} ${enabled_site_file}.disabled
222 fi
Jamie Lennox54707012013-09-17 12:07:48 +1000223 fi
224}
225
zhang-hared98a5d02013-06-21 18:18:02 +0800226# start_apache_server() - Start running apache server
Ian Wienandaee18c72014-02-21 15:35:08 +1100227function start_apache_server {
zhang-hared98a5d02013-06-21 18:18:02 +0800228 start_service $APACHE_NAME
229}
230
231# stop_apache_server() - Stop running apache server
Ian Wienandaee18c72014-02-21 15:35:08 +1100232function stop_apache_server {
zhang-hared98a5d02013-06-21 18:18:02 +0800233 if [ -n "$APACHE_NAME" ]; then
234 stop_service $APACHE_NAME
235 else
236 exit_distro_not_supported "apache configuration"
237 fi
238}
239
240# restart_apache_server
Ian Wienandaee18c72014-02-21 15:35:08 +1100241function restart_apache_server {
Morgan Fainberg2df00462014-07-15 11:06:36 -0700242 # Apache can be slow to stop, doing an explicit stop, sleep, start helps
243 # to mitigate issues where apache will claim a port it's listening on is
244 # still in use and fail to start.
Sean Dague2b85cf02017-04-13 09:02:14 -0400245 restart_service $APACHE_NAME
zhang-hared98a5d02013-06-21 18:18:02 +0800246}
247
Sean Dague2f8c88e2017-04-13 09:08:39 -0400248function write_uwsgi_config {
249 local file=$1
250 local wsgi=$2
251 local url=$3
252 local http=$4
253 local name=""
254 name=$(basename $wsgi)
rabiaa26baa2017-04-20 10:55:16 +0530255
256 # create a home for the sockets; note don't use /tmp -- apache has
257 # a private view of it on some platforms.
258 local socket_dir='/var/run/uwsgi'
Kirill Zaitsevd0db62a2017-05-26 19:02:52 +0300259
260 # /var/run will be empty on ubuntu after reboot, so we can use systemd-temptiles
261 # to automatically create $socket_dir.
262 sudo mkdir -p /etc/tmpfiles.d/
263 echo "d $socket_dir 0755 $STACK_USER root" | sudo tee /etc/tmpfiles.d/uwsgi.conf
264 sudo systemd-tmpfiles --create /etc/tmpfiles.d/uwsgi.conf
265
rabiaa26baa2017-04-20 10:55:16 +0530266 local socket="$socket_dir/${name}.socket"
Sean Dague2f8c88e2017-04-13 09:08:39 -0400267
268 # always cleanup given that we are using iniset here
269 rm -rf $file
270 iniset "$file" uwsgi wsgi-file "$wsgi"
Sean Dague2f8c88e2017-04-13 09:08:39 -0400271 iniset "$file" uwsgi processes $API_WORKERS
272 # This is running standalone
273 iniset "$file" uwsgi master true
274 # Set die-on-term & exit-on-reload so that uwsgi shuts down
275 iniset "$file" uwsgi die-on-term true
Dinesh Bhoref60f2b2017-09-05 14:40:32 +0530276 iniset "$file" uwsgi exit-on-reload false
Matthew Treinish477a9622017-08-04 11:09:26 -0400277 # Set worker-reload-mercy so that worker will not exit till the time
278 # configured after graceful shutdown
279 iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT
Sean Dague2f8c88e2017-04-13 09:08:39 -0400280 iniset "$file" uwsgi enable-threads true
Kevin Zhao7880ba62021-03-31 04:58:28 +0000281 iniset "$file" uwsgi plugins http,python3
Sean Dague2f8c88e2017-04-13 09:08:39 -0400282 # uwsgi recommends this to prevent thundering herd on accept.
283 iniset "$file" uwsgi thunder-lock true
Matthew Treinish477a9622017-08-04 11:09:26 -0400284 # Set hook to trigger graceful shutdown on SIGTERM
285 iniset "$file" uwsgi hook-master-start "unix_signal:15 gracefully_kill_them_all"
Sean Dague2f8c88e2017-04-13 09:08:39 -0400286 # Override the default size for headers from the 4k default.
287 iniset "$file" uwsgi buffer-size 65535
288 # Make sure the client doesn't try to re-use the connection.
289 iniset "$file" uwsgi add-header "Connection: close"
290 # This ensures that file descriptors aren't shared between processes.
291 iniset "$file" uwsgi lazy-apps true
Sean Dague2f8c88e2017-04-13 09:08:39 -0400292
293 # If we said bind directly to http, then do that and don't start the apache proxy
294 if [[ -n "$http" ]]; then
295 iniset "$file" uwsgi http $http
296 else
297 local apache_conf=""
298 apache_conf=$(apache_site_config_for $name)
Chris Dentb90bb1a2017-04-18 16:30:14 +0000299 iniset "$file" uwsgi socket "$socket"
300 iniset "$file" uwsgi chmod-socket 666
Jens Harbott56e75e42021-09-28 20:02:34 +0200301 echo "ProxyPass \"${url}\" \"unix:${socket}|uwsgi://uwsgi-uds-${name}\" retry=0 " | sudo tee -a $apache_conf
Sean Dague2f8c88e2017-04-13 09:08:39 -0400302 enable_apache_site $name
Ian Wienandf6a2d2c2017-04-26 10:50:29 +1000303 restart_apache_server
Sean Dague2f8c88e2017-04-13 09:08:39 -0400304 fi
305}
306
Matthew Treinish1fa65362017-06-23 22:32:37 +0000307# For services using chunked encoding, the only services known to use this
308# currently are Glance and Swift, we need to use an http proxy instead of
309# mod_proxy_uwsgi because the chunked encoding gets dropped. See:
310# https://github.com/unbit/uwsgi/issues/1540 You can workaround this on python2
311# but that involves having apache buffer the request before sending it to
Jeremy Liu2f7df512017-07-12 10:09:48 +0800312# uwsgi.
Matthew Treinish1fa65362017-06-23 22:32:37 +0000313function write_local_uwsgi_http_config {
314 local file=$1
315 local wsgi=$2
316 local url=$3
317 name=$(basename $wsgi)
318
319 # create a home for the sockets; note don't use /tmp -- apache has
320 # a private view of it on some platforms.
321
322 # always cleanup given that we are using iniset here
323 rm -rf $file
324 iniset "$file" uwsgi wsgi-file "$wsgi"
325 port=$(get_random_port)
Matthew Treinish1560efe2017-06-30 12:15:26 -0400326 iniset "$file" uwsgi http-socket "127.0.0.1:$port"
Matthew Treinish1fa65362017-06-23 22:32:37 +0000327 iniset "$file" uwsgi processes $API_WORKERS
328 # This is running standalone
329 iniset "$file" uwsgi master true
330 # Set die-on-term & exit-on-reload so that uwsgi shuts down
331 iniset "$file" uwsgi die-on-term true
Dinesh Bhoref60f2b2017-09-05 14:40:32 +0530332 iniset "$file" uwsgi exit-on-reload false
Matthew Treinish1fa65362017-06-23 22:32:37 +0000333 iniset "$file" uwsgi enable-threads true
Kevin Zhao7880ba62021-03-31 04:58:28 +0000334 iniset "$file" uwsgi plugins http,python3
Matthew Treinish1fa65362017-06-23 22:32:37 +0000335 # uwsgi recommends this to prevent thundering herd on accept.
336 iniset "$file" uwsgi thunder-lock true
Matthew Treinish477a9622017-08-04 11:09:26 -0400337 # Set hook to trigger graceful shutdown on SIGTERM
338 iniset "$file" uwsgi hook-master-start "unix_signal:15 gracefully_kill_them_all"
339 # Set worker-reload-mercy so that worker will not exit till the time
340 # configured after graceful shutdown
341 iniset "$file" uwsgi worker-reload-mercy $WORKER_TIMEOUT
Matthew Treinish1fa65362017-06-23 22:32:37 +0000342 # Override the default size for headers from the 4k default.
343 iniset "$file" uwsgi buffer-size 65535
344 # Make sure the client doesn't try to re-use the connection.
345 iniset "$file" uwsgi add-header "Connection: close"
346 # This ensures that file descriptors aren't shared between processes.
347 iniset "$file" uwsgi lazy-apps true
348 iniset "$file" uwsgi chmod-socket 666
349 iniset "$file" uwsgi http-raw-body true
350 iniset "$file" uwsgi http-chunked-input true
351 iniset "$file" uwsgi http-auto-chunked true
Matthew Treinish82d06102017-06-28 17:42:31 -0400352 iniset "$file" uwsgi http-keepalive false
Matthew Treinishb79531a2017-06-30 12:10:06 -0400353 # Increase socket timeout for slow chunked uploads
354 iniset "$file" uwsgi socket-timeout 30
Matthew Treinish1fa65362017-06-23 22:32:37 +0000355
356 enable_apache_mod proxy
357 enable_apache_mod proxy_http
358 local apache_conf=""
359 apache_conf=$(apache_site_config_for $name)
360 echo "KeepAlive Off" | sudo tee $apache_conf
Matthew Treinisha3488d52017-08-10 14:55:15 -0400361 echo "SetEnv proxy-sendchunked 1" | sudo tee -a $apache_conf
Matthew Treinish1fa65362017-06-23 22:32:37 +0000362 echo "ProxyPass \"${url}\" \"http://127.0.0.1:$port\" retry=0 " | sudo tee -a $apache_conf
363 enable_apache_site $name
364 restart_apache_server
365}
366
Dan Smith09eea0b2020-07-09 08:31:51 -0700367# Write a straight-through proxy for a service that runs locally and just needs
368# to be reachable via the main http proxy at $loc
369function write_local_proxy_http_config {
370 local name=$1
371 local url=$2
372 local loc=$3
373 local apache_conf
374 apache_conf=$(apache_site_config_for $name)
375
376 enable_apache_mod proxy
377 enable_apache_mod proxy_http
378
379 echo "KeepAlive Off" | sudo tee $apache_conf
380 echo "SetEnv proxy-sendchunked 1" | sudo tee -a $apache_conf
381 echo "ProxyPass \"${loc}\" \"$url\" retry=0 " | sudo tee -a $apache_conf
382 enable_apache_site $name
383 restart_apache_server
384}
385
Sean Dague2f8c88e2017-04-13 09:08:39 -0400386function remove_uwsgi_config {
387 local file=$1
388 local wsgi=$2
389 local name=""
390 name=$(basename $wsgi)
391
392 rm -rf $file
393 disable_apache_site $name
394}
395
zhang-hared98a5d02013-06-21 18:18:02 +0800396# Restore xtrace
Ian Wienand523f4882015-10-13 11:03:03 +1100397$_XTRACE_LIB_APACHE
zhang-hared98a5d02013-06-21 18:18:02 +0800398
Adam Spiers6a5aa7c2013-10-24 11:27:02 +0100399# Tell emacs to use shell-script-mode
400## Local variables:
401## mode: shell-script
402## End: