deekayen.iis_custom_headers
Nagłówki niestandardowe IIS
Dodaj lub usuń globalne, niestandardowe nagłówki HTTP z witryn IIS na serwerze Microsoft Windows.
Zmienne roli
Domyślna zmienna iis_custom_headers
definiuje, jaki klucz i wartość należy ustawić dla niestandardowych nagłówków HTTP. Jeśli chcesz ją nadpisać, musisz ponownie zdefiniować wszystkie nagłówki, które powinny być obecne
lub nieobecne
. Ansible nie połączy Twojej nadpisanej zmiennej z domyślnymi. Nagłówek X-Frame-Options
jest zdefiniowany przez IETF w RFC7034, aby poprawić bezpieczeństwo aplikacji webowych.
Domyślnie Ansible zrestartuje IIS na końcu zadań, ponieważ zwykle zakłada, że wykonanie win_shell
skutkuje zmianą; zmień iis_custom_headers_restart_iis
na False
, aby zapobiec restarcie IIS.
iis_custom_headers:
- { name: "X-Frame-Options", value: "SAMEORIGIN", state: "present" }
- { name: "X-Powered-By", value: "ASP", state: "absent" }
- { name: "X-Powered-By", value: "ASP.NET", state: "absent" }
iis_custom_headers_restart_iis: True
Przykład Playbooka
Zadania polegają na używaniu poleceń administracyjnych PowerShella dla serwera webowego (IIS) Add-WebConfigurationProperty i Remove-WebConfigurationProperty.
- hosts: iis_servers
roles:
- role: deekayen.iis_custom_headers
iis_custom_headers:
- { name: "Strict-Transport-Security", value: "max-age=31536000", status: "present" }
- { name: "X-Frame-Options", value: "SAMEORIGIN", status: "present" }
- { name: "X-Powered-By", value: "ASP.NET", status: "absent" }
Wynik doda elementy customHeaders do globalnej konfiguracji XML:
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Wymagania
- IIS
Zależności
Brak.
Licencja
BSD
Add or remove global, custom headers from IIS web sites on Microsoft Windows.
ansible-galaxy install deekayen.iis_custom_headers