What is wrong with my nghttp2.conf backend pattern? - nghttp2

Here is my nghttpx.conf file:
frontend=0.0.0.0,3000
backend=127.0.0.0,9901;;proto=h2
frontend-no-tls=yes
backend-no-tls=yes
workers=1
log-level=INFO
When I do:
sudo nghttpx
This error is thrown:
28/Nov/2017:15:33:30 +0900 PID19518 [ERROR] shrpx_config.cc:1418 backend: ';' must not be used in pattern
28/Nov/2017:15:33:30 +0900 PID19518 [FATAL] shrpx.cc:1714 Failed to load configuration from /etc/nghttpx/nghttpx.conf
What is wrong with my nghttpx config?

Reading man page of nghttpx we see that --backend option supports the following structure:
--backend=(<HOST>,<PORT>|unix:<PATH>)[;[<PATTERN>[:...]][[;<PARAM>]...]
Since you have backend=127.0.0.0,9901;<PATTERN>, everything that follows ; should be a valid <PATTERN>. Upon further reading of the manual we see that it says:
Since ";" and ":" are used as delimiter, must not contain these characters. Since ";" has special meaning in shell, the option value must be quoted.
Now, looking at your error, it says:
shrpx_config.cc:1418 backend: ';' must not be used in pattern
Which indicates that you have used ; in a pattern, which is not allowed. This agrees with the manual excerpt above.
So it seems that your issue is that you have one too many ; characters in your pattern. At the moment it is ;proto=h2, when it should be proto=h2. Try removing the redundant ; (i.e. it should read backend=127.0.0.0,9901;proto=h2) and see if that helps with the error you're getting.

Related

How does one write positional parameters followed by a digit in a rewrite rule in an nginx.conf file?

I've encountered an nginx.conf file that includes a rewrite rule:
rewrite "^(.*/)?8.0/shcb[0-9]+/resources/(.*)" "$18.0/resources/$2";
I'm thinking that $18 is an error. But, I'm not sure if this is like Bash programming where if one has a digit following a positional parameter that the positional parameter must be enclosed in brackets. If so, the above line could be written as:
rewrite "^(.*/)?8.0/shcb[0-9]+/resources/(.*)" "${1}8.0/resources/$2";
Have I correctly identified a problem and the solution to the problem? I could not find documentation for nginx configuration that says what to do in cases such as the above.
Both forms are valid. Nginx only supports $1 to $9 for numeric captures, so $18 looks like $1 followed by a literal 8.
The use of {} is also OK as long as you enclose the expression in quotes.

Ambiguous redirect when running configure with hush

I am running a simple linux system with busybox and hush as the shell.
When I try to run the standard "./configure" for compiling programs, I always get the following error:
/Programs/blazeos/build/bison-3.4.1 # ./configure
hush: ambiguous redirect
hush: syntax error at 'fi'
If I run it with "ash ./configure" it runs without any problems, so it seems to be related to the hush shell. Does anyone know why this is happening or how I can debug it? I have tried it with several different source packages, such as "flex", "bison", "m4" etc. and I always get the same error.
This happens in as_fn_error:
as_fn_error ()
{
as_status=$1; test $as_status -eq 0 && as_status=1
if test "$4"; then
as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
$as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
fi
$as_echo "$as_me: error: $2" >&2
as_fn_exit $as_status
} # as_fn_error
This happens because >&$4 (getting the file descriptor number to redirect to by evaluating $4) is not supported in hush. Arguably, this violates the letter of the POSIX sh standard; bolding for emphasis is mine:
The redirection operator: [n]>&word shall duplicate one output file descriptor from another, or shall close one. If word evaluates to one or more digits, the file descriptor denoted by n, or standard output if n is not specified, shall be made to be a copy of the file descriptor denoted by word
As I read the specification, "evaluates to" means that expansions should be run, so using a parameter expansion should be legal in that location. Thus, this is (arguably) a missing feature in hush that would be required for standards compliance.
If you're interested in trying to work around the issue, in all the cases where this optional parameter is used, it's given a hardcoded value of 5. Thus, you could simply change >&$4 to >&5, and this specific error would be avoided.

What am I doing wrong in monit syntax with regex?

In my monitrc i wrote next:
check file mysite.com-access.log with path /var/log/apache2/mysite.com-access.log
if content = "\/1.[01]\" 4(\d){2}" then alert
But the systemctl status monit.service says I have an error in syntax:
extsites monit[19043]: * Starting daemon monitor monit
extsites monit[19043]: /etc/monit/monitrc:305: syntax error '\d'
extsites monit[19043]: ...fail!
Earlier I put "\/1.[01]\" [45](\d){2}", but error in syntax was in '[45]'.
What am I doing wrong? All my regex was right in https://regex101.com/.
Update:
I corrected my string as if content = "^\/1\.[01]\" [45](\d){2}" then alert
but syntax error there is still.
When I am correct, monit uses POSIX regex syntax.
So following this description: https://www.regular-expressions.info/posixbrackets.html
... you could replace \d with [:digit:]
It's not logical to me, but maybe monit doesn't get the "\d" right
Following the "content"-examples in the monit-documentation, the double quote should not be the problem
It seems we should use single quotes instead double.

Why am I getting a syntax near unexpected token newline error?

I am trying to create a .bashrc file with the android dev kit in Ubuntu. Only problem is, when i edit/ add to the bashrc file, I get a "syntax error near unexpected token newline". I posted the code where the error is, specifially between android SDK home token and android NDK token. Thanks for the help
#Android SDK Home
export ANDROID_SDK=</Documents/adt-bundle-linux-x86_64-20140702>
#ANDROID NDK Home
export NDK=~/android-ndk-r10b
export PATH=$PATH: $ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
I guess that you have read something like this in a guide somewhere:
Add the following lines to your .bashrc file:
export ANDROID_SDK=<path/to/your/SDK>
# etc.
The < > are meant as placeholders, i.e. <replace this bit>. You don't need to put the path inside them, in fact you should remove them, as they are invalid syntax (which is causing the error you mention). Also, you should remove the space between $PATH: $ANDROID_SDK later on:
#Android SDK Home
export ANDROID_SDK="/Documents/adt-bundle-linux-x86_64-20140702"
#ANDROID NDK Home
export NDK="$HOME/android-ndk-r10b"
export PATH="$PATH:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools"
To be more specific, the error was caused by the > at the end of the export line, as this means "redirect the output of the command to the following file descriptor". Bash is then expecting the name of a file descriptor but all it found was a newline. The < at the beginning is also problematic, as it means "redirect the contents of this file descriptor to the command", which won't do anything useful in your case. See this wiki page for more details.
By the way, there's no harm in using double quotes, in fact, they're encouraged. Using them means that word splitting will not occur in case the name of a directory contains a space. I've added some around your assignments and changed ~ to $HOME, so that it will still do what you want (the ~ will be interpreted literally within double quotes, whereas $HOME will expand to the path of your home directory).
Angle brackets are not valid to use this way.

Semicolon on command line in linux

i am running my application in linux by providing inputs as command line. My input field contain an argument which contains ";"(semicolon) internally.(For example:123;434;5464).
This will be parsed using UTF8String encode and send.
But when i am using like this, in initial itself i am getting,
bash: 434: command not found
bash: 5464: command not found
And when i capture traffic the output contains only 123 instead 123;434;5464
But if i give without semicolon (Ex:123:434:5464),not getting any problem output coming properly as 123:434:5464
Point me how to give command line input by using semicolon as to come output. Is there any particular syntax to use while doing with semicolon.
I am running like below
./runASR.sh -ip 10.78.242.4 -port 3868 -sce 10.78.241.206 -id 85;167838865;1385433280
where -id field contain that value with issue.
; is treated an end of command character. So 123;456;5464 to bash is in fact 3 commands. To pass such meta-characters escape it with escape character \.
./command 123\;456\;5464
Or Just quote it with single quote (double quote evaluates the inner string) (Thanks Triplee, I forgot to mention this)
./command '123;456;5464'

Resources