summaryrefslogtreecommitdiff
path: root/config_files/nginx.conf
blob: 0f292af9f928cab2710a794146e3cc1220e2d1ce (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

ssl_engine pkcs11;

http {
    types_hash_max_size 4096;
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;

    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers off;

    # Server block for non-SSL routes
    server {
        listen 80;
        server_name localhost;

        # Allow specific routes without SSL
        location = / {
            proxy_pass http://localhost:5000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        location = /c {
            proxy_pass http://localhost:5000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        location ~ ^/v/ {
            proxy_pass http://localhost:5000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
        }

        # Redirect all other routes to HTTPS
        location / {
            return 301 https://$host$request_uri;
        }
    }

    # Server block for SSL routes
    server {
        listen 443 ssl;
        server_name localhost;

#        ssl_certificate /etc/nginx/certs/server.crt;
#        ssl_certificate_key /etc/nginx/certs/server.key;
#        ssl_client_certificate /etc/nginx/certs/ca.pem;
#        ssl_verify_client on;

        ssl_certificate /etc/nginx/certs/hsm_server.crt;
        ssl_certificate_key "engine:pkcs11:pkcs11:serial=DENK0104964;object=serverkey;type=private";
        ssl_client_certificate /etc/nginx/certs/hsm_chain.crt;
        ssl_verify_client on;
        # Add these debugging settings temporarily
        ssl_protocols TLSv1.2 TLSv1.3;
        ssl_session_cache shared:SSL:10m;
        ssl_session_timeout 10m;
        ssl_verify_depth 3;
        ssl_prefer_server_ciphers on;

        # Add error logging for SSL
        error_log /var/log/nginx/error.log debug;

        location / {
            proxy_pass http://localhost:5000;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }
}