diff --git a/roles/webserver/templates/conf.d/twirling.conf.j2 b/roles/webserver/templates/conf.d/twirling.conf.j2 index 3be6891..fb67921 100644 --- a/roles/webserver/templates/conf.d/twirling.conf.j2 +++ b/roles/webserver/templates/conf.d/twirling.conf.j2 @@ -13,15 +13,41 @@ server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; server_name {{ webserver_domain }} www.{{ webserver_domain }}; - include global/cert.conf; include global/header.conf; + # Path to the root of your installation + root {{ wordpress_dir }}; + add_header Strict-Transport-Security "max-age=63072000" always; - # deny access and return teapot + index index.php index.html index.htm; + + client_max_body_size 500M; + location / { - deny all; - return 418; + try_files $uri $uri/ /index.php?$args; + } + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location ~ \.php$ { + fastcgi_pass php-handler; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; } } \ No newline at end of file diff --git a/roles/webserver/templates/conf.d/wordpress.conf.j2 b/roles/webserver/templates/conf.d/wordpress.conf.j2 new file mode 100644 index 0000000..c0bd80f --- /dev/null +++ b/roles/webserver/templates/conf.d/wordpress.conf.j2 @@ -0,0 +1,53 @@ +## Managed by Ansible ## + +server { + listen 80; + listen [::]:80; + server_name dev.{{ webserver_domain }} www.dev.{{ webserver_domain }}; + # enforce https + return 301 https://$server_name$request_uri; +} + +server { + # Enable HTTP/2 + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name dev.{{ webserver_domain }} www.dev.{{ webserver_domain }}; + include global/cert.conf; + include global/header.conf; + + # Path to the root of your installation + root {{ wordpress_dir }}; + + add_header Strict-Transport-Security "max-age=63072000" always; + + index index.php index.html index.htm; + + client_max_body_size 500M; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location = /favicon.ico { + log_not_found off; + access_log off; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ { + expires max; + log_not_found off; + } + + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + + location ~ \.php$ { + fastcgi_pass php-handler; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + include fastcgi_params; + } +} \ No newline at end of file diff --git a/roles/webserver/vars/main.yml b/roles/webserver/vars/main.yml index 39403a5..b422ef2 100644 --- a/roles/webserver/vars/main.yml +++ b/roles/webserver/vars/main.yml @@ -24,6 +24,7 @@ php_modules: - "apcu" - "redis" - "pgsql" + - "mysql" # Main webserver_user: "www-data" diff --git a/roles/wordpress/meta/main.yml b/roles/wordpress/meta/main.yml new file mode 100644 index 0000000..35abc37 --- /dev/null +++ b/roles/wordpress/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: + - role: webserver diff --git a/roles/wordpress/tasks/main.yml b/roles/wordpress/tasks/main.yml new file mode 100644 index 0000000..a4ad0a5 --- /dev/null +++ b/roles/wordpress/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- name: Create wordpress directory + file: + path: "{{ wordpress_dir }}" + state: directory + owner: "{{ webserver_user }}" + group: "{{ webserver_group }}" + mode: 0755 + +- name: unpack latest wordpress version + unarchive: + remote_src: true + src: "https://wordpress.org/latest.tar.gz" + dest: "{{ wordpress_dir }}" + owner: "{{ webserver_user }}" + group: "{{ webserver_group }}" + creates: "{{ wordpress_dir }}/wp-config-sample.php" + extra_opts: + - --strip-components=1 + +- name: Copy configuration file + template: + src: wp-config.php.j2 + dest: "{{ wordpress_dir }}/wp-config.php" + owner: "{{ webserver_user }}" + group: "{{ webserver_group }}" + mode: 0600 diff --git a/roles/wordpress/templates/wp-config.php.j2 b/roles/wordpress/templates/wp-config.php.j2 new file mode 100644 index 0000000..357424b --- /dev/null +++ b/roles/wordpress/templates/wp-config.php.j2 @@ -0,0 +1,96 @@ +