add basic nginx conf

This commit is contained in:
Robert Kaussow 2017-07-15 17:24:48 +02:00
parent 775c6f8b86
commit 2358c978e0
6 changed files with 117 additions and 1 deletions

7
handlers/main.yml Normal file
View File

@ -0,0 +1,7 @@
---
- name: reload nginx
systemd:
state: reloaded
name: nginx
listen:
- "nginx_restart"

View File

@ -4,3 +4,34 @@
name: nginx
enabled: yes
state: started
- name: Prepare directories
file:
path: /var/www/vhosts
state: directory
owner: nginx
group: nginx
mode: 0750
- name: Update nginx.conf
template:
src: 'etc/nginx/nginx.conf.j2'
dest: '/etc/nginx/nginx.conf'
owner: root
group: root
mode: 0640
notify:
- nginx_restart
- name: Update conf.d files
template:
src: 'etc/nginx/conf.d/{{ item }}.j2'
dest: '/etc/nginx/conf.d/{{ item }}'
owner: root
group: root
mode: 0640
with_items:
- deafult.conf
- header.conf
notify:
- nginx_restart

View File

@ -3,7 +3,7 @@
yum:
name: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- name: Installing NGINX
- name: Installing nginx
yum:
name: nginx
state: latest

View File

@ -0,0 +1,16 @@
# {{ ansible_managed }}
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View File

@ -0,0 +1,5 @@
# {{ ansible_managed }}
add_header Strict-Transport-Security max-age=63072000;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

View File

@ -0,0 +1,57 @@
# {{ ansible_managed }}
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
types_hash_max_size 2048;
server_tokens off;
## Buffers
client_body_buffer_size 10K;
client_header_buffer_size 1k;
client_max_body_size 8m;
## Timeouts
client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;
## Gzip Settings
gzip on;
gzip_comp_level 2;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/x-javascript text/xml text/css application/xml;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
## Virtual Host Configs
include /etc/nginx/sites-enabled/*;
server_names_hash_bucket_size 64;
}