So I’m trying to find a role/create a role for my Ansible config to configure nginx.
Here’s how it currently (manually!) works:
I have numerous nginx conf files for each website that I host on this machine.
etc
API is the function, what it’s for etc, p123 is the ‘platform’ and .domain.com is well… the domain…
The configuration for api.p123.domain.com:
#main server block - api.p123.domain.com
server {
    listen 80;
    server_name api.p123.domain.com;
location / {
    #deny all access to root http://api.p123.domain.com/
    deny all;
 }
location ~* /endpoint1 {
    proxy_pass       http://api.p123.domain.com;
    include include/general/proxy_common.conf;
    access_log   /var/log/nginx/api.p123.domain.com/endpoint1.access.log main;
    error_log    /var/log/nginx/api.p123.domain.com/endpoint1.error.log info;
 }
location ~* /endpoint2 {
    proxy_pass       http://api.p123.domain.com;
    include include/general/proxy_common.conf;
    access_log   /var/log/nginx/api.p123.domain.com/endpoint2.access.log main;
    error_log    /var/log/nginx/api.p123.domain.com/endpoint2.error.log info;
 }
 access_log   /var/log/nginx/api.p123.domain.com.access.log main;
 error_log    /var/log/nginx/api.p123.domain.com.error.log info;
}
All the conf files are very similar. I’m basically asking for help/advice on how I can structure and achieve this using Ansible. Do I use templates or static files, I know I can set host_vars but these nginx conf files could in theory go to multiple servers and there could be 20-30 platforms… etc
If you have any questions just ask. Thanks in advance!
Michael