|
| 1 | +# SPDX-FileCopyrightText: 2025 Jonah Brüchert <jbb@kaidan.im> |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 4 | +# |
| 5 | + |
| 6 | +proxy_cache_path /var/cache/nginx/gtfsrt/ max_size=1g keys_zone=gtfsrt:20m; |
| 7 | + |
| 8 | +server { |
| 9 | + listen 80; |
| 10 | + server_name {{ vhost }}; |
| 11 | + |
| 12 | + # For certbot |
| 13 | + location ^~ /.well-known/acme-challenge/ { |
| 14 | + root /var/www/html/; |
| 15 | + } |
| 16 | + |
| 17 | + return 301 https://$host$request_uri; |
| 18 | +} |
| 19 | + |
| 20 | +server { |
| 21 | + listen 443 http2 ssl; |
| 22 | + listen [::]:443 http2 ssl; |
| 23 | + |
| 24 | + # Override TLS settings from included file |
| 25 | + ssl_protocols TLSv1.2 TLSv1.3; |
| 26 | + |
| 27 | + ssl_ecdh_curve X25519:prime256v1:secp384r1; |
| 28 | + ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305; |
| 29 | + ssl_prefer_server_ciphers off; |
| 30 | + |
| 31 | + # see also ssl_session_ticket_key alternative to stateful session cache |
| 32 | + ssl_session_timeout 1d; |
| 33 | + ssl_session_cache shared:MozSSL:10m; # about 40000 sessions |
| 34 | + |
| 35 | + # OCSP stapling |
| 36 | + ssl_stapling on; |
| 37 | + ssl_stapling_verify on; |
| 38 | + |
| 39 | + server_name {{ vhost }}; |
| 40 | + |
| 41 | + ssl_certificate /etc/letsencrypt/live/api.transitous.org/fullchain.pem; |
| 42 | + ssl_certificate_key /etc/letsencrypt/live/api.transitous.org/privkey.pem; |
| 43 | + |
| 44 | + charset UTF-8; |
| 45 | + |
| 46 | + # For certbot |
| 47 | + location ^~ /.well-known/acme-challenge/ { |
| 48 | + root /var/www/html/; |
| 49 | + } |
| 50 | + |
| 51 | + location ~ ^/gtfsrt/(?<feed_name>[^/]+)/trip-updates.pb { |
| 52 | + proxy_pass http://10.11.1.1:5002/$feed_name/trip-updates.pb; |
| 53 | + proxy_buffering on; |
| 54 | + proxy_cache gtfsrt; |
| 55 | + proxy_cache_revalidate off; |
| 56 | + proxy_cache_valid 200 304 5s; |
| 57 | + proxy_cache_lock on; |
| 58 | + } |
| 59 | + |
| 60 | + location ~ ^/gtfsrt/(?<feed_name>[^/]+)/vehicle-positions.pb { |
| 61 | + proxy_pass http://10.11.1.1:5001/gtfsrt/$feed_name/vehicle-positions.pb; |
| 62 | + proxy_buffering on; |
| 63 | + proxy_cache gtfsrt; |
| 64 | + proxy_cache_revalidate off; |
| 65 | + proxy_cache_valid 200 304 5s; |
| 66 | + proxy_cache_lock on; |
| 67 | + } |
| 68 | + |
| 69 | + location /api/v1/submit { |
| 70 | + proxy_pass http://10.11.1.1:5001/api/v1/submit; |
| 71 | + } |
| 72 | + |
| 73 | + location / { |
| 74 | + add_header Content-Type text/html; |
| 75 | + return 200 ' |
| 76 | +<h2>work in progress...</h2> |
| 77 | +<h3>Supported endpoints</h3> |
| 78 | +<p> |
| 79 | +<code>POST /api/v1/submit</code><br /> |
| 80 | + |
| 81 | +Example body:<br /> |
| 82 | +<code> |
| 83 | +{"position": {"lat": 43.58199, "lon": 19.52472}, "motis_trip_id": "20250722_20:10_zpcg_237", "timestamp": 12345} |
| 84 | +</code> |
| 85 | +</p> |
| 86 | +<p> |
| 87 | +<code>GET /gtfsrt/{feed}/trip-updates.pb</code> |
| 88 | +</p> |
| 89 | +<p> |
| 90 | +<code>GET /gtfsrt/{feed}/vehicle-positions.pb</code> |
| 91 | +</p>'; |
| 92 | + } |
| 93 | +} |
0 commit comments