summaryrefslogtreecommitdiffstats
path: root/ansible/roles/nginx/templates/nginx.conf.j2
blob: be1170f0335152052aed9cda407b9cf90cc6bbd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
worker_processes 2;

events {
    worker_connections 1024;
}

http {
    server_names_hash_bucket_size 64;
    error_log /var/log/nginx/error.log debug;
    access_log /var/log/nginx/access.log;

    proxy_intercept_errors on;
    proxy_send_timeout 120;
    proxy_read_timeout 300;

# http simulations
    server {
        listen 80;
        listen 443 ssl;
        server_name _;
        ssl_certificate         /etc/nginx/certs/nexus_server.crt;
        ssl_certificate_key     /etc/nginx/certs/nexus_server.key;

        keepalive_timeout  5 5;

        location / {
            root   /srv/http/$host;
            index  index.html;
        }
    }

# nexus simulations
    server {
        resolver 127.0.0.11 valid=30s;
        listen 80;
        listen 443 ssl;
        server_name {% for host in simulated_hosts.nexus -%}
                        {{ host + " " }}
                    {%- endfor %};
        ssl_certificate         /etc/nginx/certs/nexus_server.crt;
        ssl_certificate_key     /etc/nginx/certs/nexus_server.key;

        keepalive_timeout  5 5;
        proxy_buffering    off;

        # allow large uploads
        client_max_body_size 3G;

        location / {
            set $upstream_nexus nexus:8081;
            set $upstream_registry nexus:8082;
            # redirect to docker registry
            if ($http_user_agent ~ docker ) {
                proxy_pass http://$upstream_registry;
            }
            proxy_pass http://$upstream_nexus;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}