mirror of
https://github.com/HanXHX/ansible-nginx.git
synced 2026-02-28 09:22:10 +07:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb704da8d8 | ||
|
|
64a9ab7c68 | ||
|
|
c4ee6eb1a2 | ||
|
|
8789bd2c9c |
@@ -10,7 +10,7 @@ Common
|
||||
|
||||
- `name`: (M) Domain or list of domain used.
|
||||
- `template`: (D) template used to create vhost. Optional if you set `delete` to true or using `redirect_tor`.
|
||||
- `filename`: (O) Specify filename in /etc/nginx/sites-*. Do NOT specify default (reserved keyword).
|
||||
- `filename`: (O) Specify filename in /etc/nginx/sites-*. Do NOT specify default (reserved keyword). It will be used for log filenames and directories creation.
|
||||
- `state`: (O) Vhost status. Can be "present" (default), "absent" and "disabled".
|
||||
- `redirect_from`: (O) Domain list to redirect to the first `name`. You can use this key to redirect non-www to www
|
||||
- `redirect_to`: (O) Redirect all requests to this domain. Please set scheme (http:// or https:// or $sheme).
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
- name: FILE | Create root public folders (foreach nginx_vhosts)
|
||||
file: >
|
||||
path={{ nginx_root }}/{{ item.name if item.name is string else item.name[0] }}/public
|
||||
path={{ nginx_root }}/{{ item.filename | default(item.name if item.name is string else item.name[0]) }}/public
|
||||
state=directory
|
||||
owner={{ item.owner | default(nginx_user) }}
|
||||
group={{ item.group | default(nginx_user) }}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% set __proto = item.proto | default(['http']) %}
|
||||
{% set __main_name = item.name if item.name is string else item.name[0] %}
|
||||
{% set __main_name = item.filename | default(item.name if item.name is string else item.name[0]) %}
|
||||
{% set __listen = item.listen | default(['80']) %}
|
||||
{% set __listen_ssl = item.listen_ssl | default(['443']) %}
|
||||
{% set __location = item.location | default({}) %}
|
||||
@@ -38,7 +38,7 @@ server {
|
||||
include {{ nginx_helper_dir + '/ssl-' + item.ssl_template | default('strong') }};
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ item.name | join(' ') }}{% endif %};
|
||||
server_name {% if item.name is string %}{{ item.name }}{% else %}{{ "\n\t\t" }}{{ item.name | join("\n\t\t") }}{% endif %};
|
||||
{% block root %}
|
||||
{% if item.root is defined %}
|
||||
root {{ item.root }};
|
||||
|
||||
@@ -3,3 +3,9 @@
|
||||
{% block template_try_files %}
|
||||
try_files $uri $uri/ /index.php?$args;
|
||||
{% endblock %}
|
||||
|
||||
{% block template_custom_location %}
|
||||
location ~* /(?:uploads|files)/.*\.php$ {
|
||||
deny all;
|
||||
}
|
||||
{% endblock %}
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
-----END CERTIFICATE-----
|
||||
nginx_custom_http:
|
||||
- 'add_header X-ansible 1;'
|
||||
nginx_default_vhost: 'test.local'
|
||||
nginx_default_vhost: 'first-test'
|
||||
nginx_default_vhost_ssl: 'test-ssl-predeployed.local'
|
||||
nginx_vhosts:
|
||||
- name:
|
||||
@@ -120,7 +120,7 @@
|
||||
'X-Frame-Options': 'deny always'
|
||||
'X-ansible-default': '1'
|
||||
manage_local_content: false
|
||||
use_error_log: false
|
||||
use_error_log: true
|
||||
more:
|
||||
- 'autoindex off;'
|
||||
location:
|
||||
@@ -209,7 +209,7 @@
|
||||
with_items: ['test-php.local', 'test-php-index.local']
|
||||
- name: -- Add HTML file --
|
||||
copy: dest="{{ item }}/index.html" content="Index HTML test OK\n"
|
||||
with_items: ['{{ nginx_root }}/test.local/public', '/var/tmp', '{{ nginx_root }}/test-htpasswd-all.local/public', '{{ nginx_root }}/test-ssl.local/public', '{{ nginx_root }}/test-ssl-predeployed.local/public']
|
||||
with_items: ['{{ nginx_root }}/first-test/public', '/var/tmp', '{{ nginx_root }}/test-htpasswd-all.local/public', '{{ nginx_root }}/test-ssl.local/public', '{{ nginx_root }}/test-ssl-predeployed.local/public']
|
||||
- name: -- Create directory --
|
||||
file: path={{ nginx_root }}/test-htpasswd.local/public/hello state=directory
|
||||
- name: -- Add HTML file hello --
|
||||
|
||||
Reference in New Issue
Block a user