Add basic support for nginx

Nginx is popular server and great for static content. Add rules for its
default configuration.
This commit is contained in:
Petr Menšík 2022-03-22 16:12:49 +01:00
parent 12bbd4ec45
commit e689bd578d
2 changed files with 60 additions and 3 deletions

21
nginx-web-assets.conf Normal file
View File

@ -0,0 +1,21 @@
# allow access to /.sysassets
location /.sysassets/fonts {
alias /usr/share/fonts;
autoindex off;
}
location /.sysassets/javascript {
alias /usr/share/javascript;
autoindex off;
}
location /.sysassets/js {
alias /usr/share/javascript;
autoindex off;
}
location /.sysassets/ {
alias /usr/share/web-assets;
autoindex off;
}

View File

@ -1,10 +1,11 @@
#disable the httpd stuff while we're waiting on getting the path issues
#cleared up
%global enable_httpd 1
%bcond_without nginx
Name: web-assets
Version: 5
Release: 15%{?dist}
Release: 16%{?dist}
Summary: A simple framework for bits pushed to browsers
BuildArch: noarch
@ -15,6 +16,7 @@ Source1: LICENSE
Source2: macros.web-assets
Source3: web-assets.conf
Source4: README.devel
Source5: nginx-web-assets.conf
%description
%{summary}.
@ -48,6 +50,17 @@ Requires(postun): systemd
%{summary}.
%endif
%if %{with nginx}
%package nginx
Summary: Web Assets aliases for the nginx daemon
License: MIT
Requires: web-assets-filesystem = %{version}-%{release}
Requires: nginx
%description nginx
%{summary}.
%endif
%prep
%setup -c -T
cp %{SOURCE1} LICENSE
@ -66,6 +79,10 @@ ln -sf ../fonts %{buildroot}%{_datadir}/web-assets/fonts
install -Dpm0644 %{SOURCE2} %{buildroot}%{_rpmconfigdir}/macros.d/macros.web-assets
%if %{with nginx}
install -Dpm0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/nginx/default.d/web-assets.conf
%endif
%if 0%{?enable_httpd}
install -Dpm0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/httpd/conf.d/web-assets.conf
@ -76,21 +93,40 @@ systemctl reload-or-try-restart httpd.service || :
systemctl reload-or-try-restart httpd.service || :
%endif
%if %{with nginx}
%post nginx
[ -x %{_bindir}/systemctl ] && systemctl reload-or-try-restart nginx.service || :
%postun nginx
[ -x %{_bindir}/systemctl ] && systemctl reload-or-try-restart nginx.service || :
%endif
%files filesystem
%{_datadir}/web-assets
%{_datadir}/javascript
%files devel
%{_rpmconfigdir}/macros.d/macros.web-assets
%doc LICENSE README.devel
%license LICENSE
%doc README.devel
%if 0%{?enable_httpd}
%files httpd
%config(noreplace) %{_sysconfdir}/httpd/conf.d/web-assets.conf
%doc LICENSE
%license LICENSE
%endif
%if %{with nginx}
%files nginx
%config(noreplace) %{_sysconfdir}/nginx/default.d/web-assets.conf
%license LICENSE
%endif
%changelog
* Tue Mar 22 2022 Petr Menšík <pemensik@redhat.com> - 5-16
- Add nginx aliases support
* Sat Jan 22 2022 Fedora Release Engineering <releng@fedoraproject.org> - 5-15
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild