Commit 383ba9c0 authored by Jakub Jirutka's avatar Jakub Jirutka
Browse files

main/nginx: change default dir for vhost configs from conf.d to http.d

It was a mistake (and I admit it, it was my mistake) to start using conf.d
for vhost configs. This directory is better suited for configs to be
included in the root context, not in the http context. And it's even more
evident since the introduction of the stream module - where should be
stream servers defined? I think that the most intuitive location is a
stream.d directory. Similarly, http servers should be in http.d directory.

The new layout for Alpine is the following:

- nginx.conf - the main nginx config that includes config snippets
- conf.d/*.conf - configs included in the root context (will be added later)
- http.d/*.conf - configs included in the http context (new, former conf.d)
- modules/*.conf - configs for loading modules
- stream.d/*.conf - configs included in the stream context (new)
parent 8bb0fb27
......@@ -60,7 +60,7 @@ pkgusers="nginx"
pkggroups="$_grp_ngx $_grp_www"
install="$pkgname.pre-install $"
install="$pkgname.pre-install $ $"
subpackages="$pkgname-debug $pkgname-doc $pkgname-openrc $pkgname-vim::noarch"
......@@ -335,16 +335,18 @@ package() {
cd "$pkgdir"
install -Dm644 "$srcdir"/nginx.conf ./etc/$pkgname/nginx.conf
install -Dm644 "$srcdir"/default.conf ./etc/$pkgname/conf.d/default.conf
install -dm755 ./etc/$pkgname/http.d ./etc/$pkgname/modules
install -Dm755 "$srcdir"/$pkgname.initd ./etc/init.d/$pkgname
install -Dm644 "$srcdir"/$pkgname.confd ./etc/conf.d/$pkgname
install -Dm644 "$srcdir"/$pkgname.logrotate ./etc/logrotate.d/$pkgname
install -dm755 ./etc/$pkgname/modules
install -dm750 -o $pkgusers -g $_grp_ngx ./var/lib/$pkgname
install -dm700 -o $pkgusers -g $_grp_ngx ./var/lib/$pkgname/tmp
install -dm755 -g $_grp_www ./var/www/localhost/htdocs
install -Dm644 "$srcdir"/default.conf ./usr/share/$pkgname/http-default_server.conf
install -dm755 ./var/log
mv ./var/lib/$pkgname/logs ./var/log/$pkgname
chown $pkgusers:$_grp_ngx var/log/$pkgname
......@@ -438,7 +440,7 @@ e87d9c8cbebc147881e3a40e6944acfe836f29eb7b393af0465b04dd27f1fa42f17ab63d2bcc7505
48689e09dc87f395095408127669c9f21a32c13b1b700ffad225db0c8920ae9e4f08e88332c12c01d96ded2d091ad2033885d81d5d7c9479745b10620f36562d nginx-module-vts~set-histogram-buckets-on-first-request.patch
09ec9f18323197eafa55ff68e8c836ad3dd830e6cd3bd4aeaf34e179ef3f72f734a0117288c1c58813aff59f3f1f0f29ccd772a672e17551e7a4fd0693a89c92 traffic-accounting-nginx-module~disable-stream-module.patch
ac0f912ae90e0083cc761a622290223edeed0bd32213bbe766d637ac2dfd9835d163e5d16ef28740cbad05d6d92cc418d62df3413c70b4f2c63db02f8ca1c7cc nginx_cookie_flag_module~fix-mem-allocations.patch
47f43a3bd65aedbf64279266a54183d4c1570b2de69988333d22269ad635af74220ad874857f94cf1598f88d00a312b60fab2475eee688e21822df917bdec2fa nginx.conf
69082ffa821dd945bcbe92c4e9e93beeb60892fe235adde26613d4d6a416c14542f92bb1b2751d0dae7cc075d2eea85a70b638bd6eaa6b4834e46f77eec2a7fd nginx.conf
0907f69dc2d3dc1bad3a04fb6673f741f1a8be964e22b306ef9ae2f8e736e1f5733a8884bfe54f3553fff5132a0e5336716250f54272c3fec2177d6ba16986f3 default.conf
f3321a45736697009817db335ad36d3f1d05f60d98ac90a943220cdd4c00c52632f018db6a6076d5431a483525aacc5725b87b765b590e2f63b3ef98c5b16bd8 stream.conf
09b110693e3f4377349ccea3c43cb8199c8579ee351eae34283299be99fdf764b0c1bddd552e13e4d671b194501618b29c822e1ad53b34101a73a63954363dbb nginx.logrotate
......@@ -97,7 +97,11 @@ http {
# Includes virtual hosts configs.
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/http.d/*.conf;
# WARNING: Don't use this directory for virtual hosts anymore.
# This include will be moved to the root context in Alpine 3.14.
#include /etc/nginx/conf.d/*.conf;
# TIP: Uncomment if you use stream module.
# Install config with the default http server to the new location (since 1.18.0-r13).
if ! [ -e /etc/nginx/http.d/default.conf ]; then
install -m644 /usr/share/nginx/http-default_server.conf /etc/nginx/http.d/default.conf
# TODO: Remove before Alpine 3.14.
if ! [ -e /etc/nginx/conf.d ]; then
# Symlink conf.d to http.d for backward compatibility.
ln -s http.d /etc/nginx/conf.d
exit 0
......@@ -20,4 +20,46 @@ if [ "$(apk version -t "$ver_old" "1.10.1-r3")" = "<" ]; then
# Handle transition from /etc/nginx/conf.d to /etc/nginx/http.d.
if [ "$(apk version -t "$ver_old" '1.18.0-r13')" = '<' ]; then
if [ -z "$(ls -A /etc/nginx/conf.d 2>/dev/null)" ]; then
# conf.d dir doesn't exist or is empty, so the user doesn't use it.
# Thus we can install default.conf to the new directory.
install -m644 "$default_conf" /etc/nginx/http.d/default.conf
# Symlink conf.d to http.d for backward compatibility.
rmdir /etc/nginx/conf.d 2>/dev/null
ln -s http.d /etc/nginx/conf.d
if ! [ -e /etc/nginx/conf.d/default.conf ]; then
# conf.d dir exists and is not empty, but there's no default.conf
# file, so the user probably did not modify it and apk has removed
# it during this upgrade. Prior this version, the default.conf
# would be installed, so install it now for backward compatibility.
install -m644 "$default_conf" /etc/nginx/conf.d/default.conf
if ! [ -e /etc/nginx/nginx.conf.apk-new ]; then
# There's no updated nginx.conf, so the user didn't modify this
# config and apk replaced it during this upgrade. However, the
# user has some vhost configs in the old directory, so we have
# to revert the include back to the legacy path.
sed -i \
-e 's|include /etc/nginx/http\.d|#&|' \
-e 's|#\(include /etc/nginx/conf\.d\)|\1|' \
cat >&2 <<-EOF
* The default and preferred location for nginx vhost configs has been changed
* from /etc/nginx/conf.d to /etc/nginx/http.d. Although we did our best to not
* break existing setups by this upgrade, we strongly recommend to verify it.
exit 0
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment