ansible/roles/nginx/templates/nginx.conf
user www-data;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 1024;
}
http {
server_tokens off;
fastcgi_read_timeout {{ nginx_read_timeout }};
client_max_body_size {{ nginx_client_max_body_size }};
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_response_time';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name "";
return 444;
}
server {
listen 80;
listen [::]:80;
server_name {{ nginx_servername }} app.{{ nginx_servername }} repo.{{ nginx_servername }} *.repo.{{ nginx_servername }};
root {{ app_current_dir }}/public;
{% if nginx_proxy_secret != "" %}
if ($http_x_repman_proxy != "{{ nginx_proxy_secret }}") {
return 444;
}
{% endif %}
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
location ~ ^/index\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_pass unix:{{ php_fastcgi_listen }};
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
include fastcgi_params;
internal;
}
error_log "{{ nginx_app_error_log }}";
access_log "{{ nginx_app_access_log }}" main;
}
}