ctucx.git: trainsearch

web based trip-planner, fork of https://cyberchaos.dev/yuka/trainsearch

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 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
daemon off;
worker_processes  1;

pid /tmp/nginx.pid;

error_log /dev/stdout debug;

events {
    use epoll;
    worker_connections  128;
}

http {
	server_tokens off;
	charset       utf-8;

	map $vendotarget $vendopath {
		default   no;
		locations  '/mob/location/search';
		'location' '/mob/location/details';
		journeys   '/mob/angebote/fahrplan';
		journey    '/mob/angebote/recon';
		departures '/mob/bahnhofstafel/abfahrt';
		trip       '/mob/zuglauf';
	}

	map $hafastarget $hafasurl {
		default no;
		nahsh   nah.sh.hafas.de;
		rmv     www.rmv.de;
		vrn     vrn.hafas.de;
		bvg     bvg-apps-ext.hafas.de;
		oebb    fahrplan.oebb.at;
	}

	map $hafastarget $hafaspath {
		default no;
		nahsh   '/bin/mgate.exe';
		rmv     '/auskunft/bin/jp/mgate.exe';
		vrn     '/bin/mgate.exe';
		bvg     '/bin/mgate.exe';
		oebb    '/bin/mgate.exe';
	}

	server {
		server_name   localhost;
		listen        127.0.0.1:1234;

		access_log /dev/stdout;

		location /db/vehicle-sequence {
			resolver 8.8.8.8;
			proxy_ssl_server_name on;
			proxy_ssl_name www.bahn.de;
			proxy_set_header Host www.bahn.de;
			proxy_pass https://www.bahn.de/web/api/reisebegleitung/wagenreihung/vehicle-sequence$is_args$args;
		}


		location ~ ^/db/vendo/(?<vendotarget>[a-z]+)(/([^\r\n].*))?$ {
			set $vendodomain 'app.vendo.noncd.db.de';

			add_header x-input $1.$2 always;

			if ($vendopath = no) {
				return 400;
			}

			if ($vendotarget = 'trip') {
				set $vendopath '$vendopath$2';
			}

			if ($vendotarget = 'location') {
				set $vendopath '$vendopath$2';
			}

			add_header x-target https://$vendodomain$vendopath always;

			resolver 8.8.8.8; 
			proxy_ssl_server_name on;
			proxy_ssl_name $vendodomain;
			proxy_set_header Host $vendodomain;
			proxy_pass https://$vendodomain$vendopath;
		}

		location ~ ^/hafas/(?<hafastarget>.*)$ {
			if ($hafasurl = no) {
				return 400;
			}

			resolver 8.8.8.8;
			proxy_ssl_server_name on;
			proxy_ssl_name $hafasurl;
			proxy_set_header Host $hafasurl;
			proxy_pass https://$hafasurl$hafaspath;
		}
	}

}