2 #***************************************************************************
4 # Project ___| | | | _ \| |
6 # | (__| |_| | _ <| |___
7 # \___|\___/|_| \_\_____|
9 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at https://curl.se/docs/copyright.html.
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
22 # SPDX-License-Identifier: curl
24 #***************************************************************************
26 # This script invokes nghttpx properly to have it serve HTTP/2 for us.
27 # nghttpx runs as a proxy in front of our "actual" HTTP/1 server.
33 my $pidfile = "$logdir/nghttpx.pid";
34 my $logfile = "$logdir/http2.log";
35 my $nghttpx = "nghttpx";
36 my $listenport = 9015;
37 my $listenport2 = 9016;
38 my $connect = "127.0.0.1,8990";
39 my $conf = "nghttpx.conf";
40 my $cert = "Server-localhost-sv";
42 #***************************************************************************
43 # Process command line options
46 if($ARGV[0] eq '--verbose') {
49 elsif($ARGV[0] eq '--pidfile') {
55 elsif($ARGV[0] eq '--nghttpx') {
61 elsif($ARGV[0] eq '--port') {
63 $listenport = $ARGV[1];
67 elsif($ARGV[0] eq '--port2') {
69 $listenport2 = $ARGV[1];
73 elsif($ARGV[0] eq '--connect') {
80 elsif($ARGV[0] eq '--logfile') {
86 elsif($ARGV[0] eq '--logdir') {
92 elsif($ARGV[0] eq '--conf') {
99 print STDERR "\nWarning: http2-server.pl unknown parameter: $ARGV[0]\n";
104 my $srcdir = dirname(__FILE__);
105 $certfile = "$srcdir/certs/$cert.pem";
106 $keyfile = "$srcdir/certs/$cert.key";
107 $certfile = abs_path($certfile);
108 $keyfile = abs_path($keyfile);
110 my $cmdline="$nghttpx --backend=$connect ".
111 "--frontend=\"*,$listenport;no-tls\" ".
112 "--frontend=\"*,$listenport2\" ".
114 "--pid-file=$pidfile ".
116 "--errorlog-file=$logfile ".
117 "$keyfile $certfile";
118 print "RUN: $cmdline\n" if($verbose);
119 system("$cmdline 2>/dev/null");