blob: 09ada660bb5b8a127407af025214213d1918e64e [file] [log] [blame]
xf.li6c8fc1e2023-08-12 00:11:09 -07001#!/usr/bin/env perl
2#***************************************************************************
3# _ _ ____ _
4# Project ___| | | | _ \| |
5# / __| | | | |_) | |
6# | (__| |_| | _ <| |___
7# \___|\___/|_| \_\_____|
8#
9# Copyright (C) 2016 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
10#
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.
14#
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.
18#
19# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20# KIND, either express or implied.
21#
22# SPDX-License-Identifier: curl
23#
24#***************************************************************************
25
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.
28
29my $pidfile = "log/nghttpx.pid";
30my $logfile = "log/http2.log";
31my $nghttpx = "nghttpx";
32my $listenport = 9015;
33my $connect = "127.0.0.1,8990";
34
35#***************************************************************************
36# Process command line options
37#
38while(@ARGV) {
39 if($ARGV[0] eq '--verbose') {
40 $verbose = 1;
41 }
42 elsif($ARGV[0] eq '--pidfile') {
43 if($ARGV[1]) {
44 $pidfile = $ARGV[1];
45 shift @ARGV;
46 }
47 }
48 elsif($ARGV[0] eq '--nghttpx') {
49 if($ARGV[1]) {
50 $nghttpx = $ARGV[1];
51 shift @ARGV;
52 }
53 }
54 elsif($ARGV[0] eq '--port') {
55 if($ARGV[1]) {
56 $listenport = $ARGV[1];
57 shift @ARGV;
58 }
59 }
60 elsif($ARGV[0] eq '--connect') {
61 if($ARGV[1]) {
62 $connect = $ARGV[1];
63 $connect =~ s/:/,/;
64 shift @ARGV;
65 }
66 }
67 elsif($ARGV[0] eq '--logfile') {
68 if($ARGV[1]) {
69 $logfile = $ARGV[1];
70 shift @ARGV;
71 }
72 }
73 else {
74 print STDERR "\nWarning: http2-server.pl unknown parameter: $ARGV[0]\n";
75 }
76 shift @ARGV;
77}
78
79my $cmdline="$nghttpx --backend=$connect ".
80 "--frontend=\"*,$listenport;no-tls\" ".
81 "--log-level=INFO ".
82 "--pid-file=$pidfile ".
83 "--errorlog-file=$logfile";
84print "RUN: $cmdline\n" if($verbose);
85system("$cmdline 2>/dev/null");