WildFly expression variables - configuration

Is there any complete list of variables supported in WildFly web configuration expressions (eg rewrite filters)? Like %U, %h, %p...
<filters>
<rewrite name="http-to-https" redirect="true" target="https://myhostname:8443%U"/>
</filters>
<server name="default-server">
<host name="default-host" alias="localhost">
...
<filter-ref name="http-to-https" predicate="equals(%p,8080)"/>

Current WildFly (15) uses Undertow 2.0 so take a look at Undertow documentation on predicates:
http://undertow.io/undertow-docs/undertow-docs-2.0.0/predicates-attributes-handlers.html

These are the attributes used by AccessLogHandler.java for log.
%a - Remote IP address
%A - Local IP address
%b - Bytes sent, excluding HTTP headers, or '-' if no bytes
were sent
%B - Bytes sent, excluding HTTP headers
%h - Remote host name
%H - Request protocol
%l - Remote logical username from identd (always returns '-')
%m - Request method
%p - Local port
%q - Query string (excluding the '?' character)
%r - First line of the request
%s - HTTP status code of the response
%t - Date and time, in Common Log Format format
%u - Remote user that was authenticated
%U - Requested URL path
%v - Local server name
%D - Time taken to process the request, in millis
%T - Time taken to process the request, in seconds
%I - current Request thread name (can compare later with stacktraces)
In addition, the caller can specify one of the following aliases for
commonly utilized patterns:
common - %h %l %u %t "%r" %s %b
combined -
%h %l %u %t "%r" %s %b "%{i,Referer}" "%{i,User-Agent}"
There is also support to write information from the cookie, incoming
header, or the session
It is modeled after the apache syntax:
%{i,xxx} for incoming headers
%{o,xxx} for outgoing response headers
%{c,xxx} for a specific cookie
%{r,xxx} xxx is an attribute in the ServletRequest
%{s,xxx} xxx is an attribute in the HttpSession

Related

DNS configuration on virtual machine without internet

Im trying to configure DNS server on my virtual computer without internet connection.
I'm using PowerDNS with BIND backend.
Here is my configuration of zone:
$ORIGIN example.com.
$TTL 86400
# IN SOA example2.com. (
2017020401 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum TTL
example.com. 172800 IN NS example1.com.
example.com. 172800 IN NS example2.com.
example.com. 172800 IN NS example3.com.
Im testing server with command dig, which looks like this :
root#osboxes:~# dig example.com #127.0.0.1 -p 5301
; <<>> DiG 9.16.1-Ubuntu <<>> example.com #127.0.0.1 -p 5301
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13819
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;example.com. IN A
;; AUTHORITY SECTION:
example.com. 3600 IN SOA example2.com. 2017020401.example.com. 3600 1800 604800 86400 3600
;; Query time: 180 msec
;; SERVER: 127.0.0.1#5301(127.0.0.1)
;; WHEN: Wed Feb 03 16:45:50 EST 2021
;; MSG SIZE rcvd: 96
I want the request to be delegated to other servers example1.com, example2.com and example3.com.
For that, I need to have my NS records in AUTHORITY SECTION of the dig output.
However, its not happening, there is only the SOA record.
I tried to remove the SOA record, but afterwards I have no record in AUTHORITY SECTION.
Can somebody help me solving this problem please? What am I missing?
EDIT : adding configuration
recursor.conf
local-address=0.0.0.0
local-port=5301
allow-from=127.0.0.0/8, 10.0.0.0/8
forward-zones=example.com=127.0.0.1:5300
pdns.conf
launch=bind
bind-config=/etc/powerdns/named.conf
local-address=127.0.0.1
local-port=5300
named.conf
zone "example.com" IN {
type slave; # type of zone
file "/var/lib/powerdns/zone.net"; # location of forward zone file
allow-query { any; };
};
/var/lib/powerdns/zone.net
$ORIGIN example.com.
$TTL 86400
# IN SOA example2.com. (
2017020401 ; serial
3600 ; refresh
1800 ; retry
604800 ; expire
86400 ) ; minimum TTL
example.com. 172800 IN NS example1.com.
example.com. 172800 IN NS example2.com.
example.com. 172800 IN NS example3.com.
EDIT
I'm assuming you're using BIND9. If you are, you need to set minimal-responses to no in your options section. Most likely that's in /etc/bind/named.conf.options, if it's not there, then check /etc/bind/named.conf.
I found this on readthedocs for BIND, scroll down a bit and you'll see minimal-responses highlighted.
END EDIT
The dig query you tried is for example.com type A, which is an IPv4 address. Your zone file doesn't have any A records for example.com, so one thing you could do is add one, for example:
example.com. 172800 IN A 1.2.3.4
Then your dig query for example.com should return 1.2.3.4 in the answer section, and the NS records in the authority section (though that may depend on your DNS server's configuration).
If you add A (or AAAA) records for example1.com, example 2.com, and example3.com and then do your dig command again, you'll probably get those A records in the additional section. (IIRC, that's known as "glue")
Just a little more background, the response you got from your dig query is often called a "No Data" response. That means there's a record for the name you looked up (example.com), but it's a different type (NS) than the one you asked for (A), so it returns a NOERROR rcode with no answer (there's no answer section). If you ask for a name that doesn't exist at all, you'll get the same thing (no answer section), but an NXDOMAIN rcode instead of NOERROR.

TCL/Expect encoding

I have an el5 system with "tcl" and "expect", intended use for use Asterisk Call Manager / 1.0, I make a telnet connection to send messages (use of VGSMII, with vgsm_sms_tx command).
When I actually make the connection in telnet and write the commands, and the text of the messages, no problem. Instead when I do it to the script, Asterisk Call Manager is unable to send messages with special characters (example: € èé)
The O.system uses en_US.utf-8 as the encoding.
TCL should use iso-8859 (if I'm not wrong).
I tried to set up
set var1 [encoding convertto utf-8 $var0]
but nothing seems to change...
I also tried with the gsm0338
Thanks
Normally, you'd want the same encoding to be used by Tcl and by the far end program that you're using at the moment; it's pretty rare for other programs in-between (such as ssh or telnet) to do much other than carry the majority of bytes through unchanged. If the other side expects to be UTF-8, Tcl should be told to use UTF-8 on that channel. In theory, you can put the channel into binary mode and use encoding convertto utf-8 to generate the bytes to write… but that's horrible and easy to get wrong so it should be avoided when you're not doing something complicated.
It's not very well documented, but Expect's spawn IDs are (a special type of) Tcl channels. That means you can, after the spawn, do this once:
# Assuming you're not in a procedure; use $::spawn_id otherwise
fconfigure $spawn_id -encoding utf-8
and everything should Just Work™ from there on.
In the end, i convert only the messages in base64, with this works fine.
i follow this(in view mode, doesn't view anything):
http://open.voismart.it/index.php?title=VGSM_Manager_Interface&action=edit
=vgsm_sms_tx Action=
The vGSM Asterisk's channel driver provides a manager action to send Short Messages (SMS). The action is named '''vgsm_sms_tx'''.
If the message does not contain characters in the [http://www.dreamfabric.com/sms/default_alphabet.html GSM default alphabet] the message will be sent with UCS2 but the available characters will be reduced to 80.
In pre-0.21.0 releases the action was named '''VGSMsmstx'''. This name is now deprecated and vgsm_sms_tx will be supported starting from 0.21.0.
== Parameters ==
{| class="wikitable"
!Header
!Usage
!Description
|-
|'''To'''
|Mandatory
|The phone number to which to send the SMS. It may be in national format (347123456) or international format (+39347123456). The 00 or other operator-specific prefixes are not supported.
|-
|'''X-SMS-ME'''
|Optional
|Specifies the interface on which the SMS is sent. If not specified the SMS is sent on the first available interface. Huntgroups are supported using the <tt>huntgroup:name</tt> syntax, but sending will not currently be retried if there is a failure on the chosen module. Also, only sequential hunting is supported.
|-
|'''X-SMS-SMCC-Number'''
|Optional
|If present, forces the use of a specific Service Center.
|-
|'''X-SMS-Reject-Duplicates'''
|Optional
|Maps to TP-Reject-Duplicates (TP-RD), Ref. TS 100 901, §9.2.3.27
|-
|'''X-SMS-Reply-Path'''
|Optional
|Maps to TP-Reply-Path (TP-RP), Ref. TS 100 901, §9.2.3.17
|-
|'''X-SMS-Status-Report-Request'''
|Optional
|Maps to TP-Status-Report-Request (TP-SRR), Ref. TS 100 901, §9.2.3.5
|-
|'''X-SMS-Message-Reference'''
|Optional
|Maps to TP-Message-Reference (TP-MR), Ref. TS 100 901, §9.2.3.6
|-
|'''X-SMS-Validity-Period'''
|Optional
|Maps to TP-Validity-Period (TP-VP), Ref. TS 100 901, §9.2.3.12, specifies for how much time (in seconds, starting from now) the SMS message is valid and delivery should be attempted. If not specified the default value is 4 days.
|-
|'''X-SMS-Class'''
|Optional
|If specified sets the SMS class. Class 0 is used for flash SMSes, class 3 is used for normal messages. The use of other classes has to be evaluated.
|-
|'''X-SMS-Concatenate-RefID'''
|Optional
|In UDH Concatenate IE, specifies the Reference Id of the split message
|-
|'''X-SMS-Concatenate-Total-Messages'''
|Optional
|In UDH Concatenate IE, specifies the number of messages in which the main message is split
|-
|'''X-SMS-Concatenate-Sequence-Number'''
|Optional
|In UDH Concatenate IE, specifies the sequence number of this messages
|-
|'''Content-Type'''
|Optional
|Defines the content type; Only ''text/plain'' is currently supported
|-
|'''Content-Transfer-Encoding'''
|Optional
|Defines the content encoding, valid values are:
* ''7bit'': 7-bit ASCII text
* ''hex'': Hex-Encoded text
* ''base64'': Base64-encoded text
* ''quoted-printable'': Quoted-printable escaping
|-
|'''Content'''
'''Content2'''
'''ContentN'''
|Mandatory
|The SMS body in the encoding specified in the Content-Transfer-Encoding or 7-bit ASCII if that header is missing.
|-
|}
''IMPORTANT'': Asterisk Manager Interface does NOT support line lengths greater that 80 characters, including the header name, thus, it is mandatory to split the '''Content''' header in more headers with at most 65 characters each, unfortunately the splitting is supported starting from vstuff 1.0.0 which is not yet released. Please use a snapshot in the meantime.
''FIXME!!'' This statement needs to be confirmed. Asterisk version 1.4.14 allows a message of 160 char in one single Content: line. Will a message of size > 160 trigger more than 1 SMS?
===Response statuses===
=====Success=====
* 201 Message Sent
=====Temporary failures =====
* 400 Network out of order
* 401 Module is not ready
* 402 Module is not registered
* 403 Module is already sending a message
* 404 Cannot find an available module
* 405 Cannot allocate message
* 406 Out of memory
=====Permanent failures=====
* 501 Cannot find module
* 502 Services Center number not set
* 503 Cannot open iconv context
* 504 Invalid Content-Type
* 505 Unsupported content-Type
* 506 Unsupported Content-Transfer-Encoding
* 507 Charset conversion error
* 508 Cannot find huntgroup
* 509 Content: header missing
* 510 To: header missing
* 511 Message too big
* 512 Unspecified message preparation error
== Example of a SMS sending session ==
===Authentication===
[root#voismart-4-000000 chan_vgsm]# telnet localhost 5038
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Asterisk Call Manager/1.0
Action: login
Username: sms
Secret: sms
Response: Success
Message: Authentication accepted
===Simple ASCII message===
Action: vgsm_sms_tx
To: +393471234567
Content-type: text/plain; charset=ASCII
Content: Ciao, questo e' un SMS. Niente caratteri 8-bit, qui.
Status: 201
X-SMS-Reference: 22
Response: Success
Message: Message sent
===UTF-8 encoded message with characters in the GSM alphabet===
Action: vgsm_sms_tx
To: +393471234567
X-SMS-ME: vodafone
X-SMS-Class: 3
X-SMS-SMCC-Number: +393492000200
Content-type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
Content: VGVzdCBVVEYtOCBlbmNvZGluZyB3aXRoIGNoYXJhY3RlcnMgaW4gdGhlIEdTTSBhbHBoY
Content2: WJldC4gQWNjZW50czogw6DDqMOsw7LDuSwgR3JlZWsgTGV0dGVyczogzqbOk86bzqnOo
Content3: M6ozqPOmM6eLCBPdGhlcjogwqXCo8OHw5jDuMOFw6XigqzDhsOmw5/DicKkCg==
===UTF-8 encoded message with characters outside the GSM alphabet===
Action: vgsm_sms_tx
To: +393471234567
X-SMS-ME: vodafone
X-SMS-Class: 3
X-SMS-SMCC-Number: +393492000200
Content-type: text/plain; charset=UTF-8
Content-Transfer-Encoding: base64
Content: Q2hhcnMgb3V0c2lkZSBHU00gY2hhcnNldC4gQXJhYjog27Hbstuz27Tbtdu227fbuNu5L
Content2: CBIZWI6INeQ15HXkteT15TXldeW15fXmNeZCg==
===Concatenated messages===
Action: vgsm_sms_tx
To: +393471234567
X-SMS-ME: vodafone
X-SMS-Concatenate-RefID: 58
X-SMS-Concatenate-Total-Messages: 2
X-SMS-Concatenate-Sequence-Number: 1
Content-type: text/plain; charset=ASCII
Content: This is message part 1 of 2, that will be followed by part 2 of 2 which
Content2: will be sent later.
Action: vgsm_sms_tx
To: +393471234567
X-SMS-ME: vodafone
X-SMS-Concatenate-RefID: 58
X-SMS-Concatenate-Total-Messages: 2
X-SMS-Concatenate-Sequence-Number: 2
Content-type: text/plain; charset=ASCII
Content: This is part 2 of 2, the message is now complete. We can thus send up
Content2: to 255 parts for a total of 40,800 charaters (for just 38 Euros!)
===Sending message using a huntgroup===
Action: vgsm_sms_tx
To: +34600123456
X-SMS-ME: huntgroup:safaricom
Content-type: text/plain; charset=ASCII
Content: This message is sent using one of the several ME in the group safaricom
=vgsm_sms_rx Event=
On reception of an inbound SMS (SMS-DELIVERY) the message will also be reported as a manager event, however, acknowledgment still relies on SMS spooler to handle the message. This event is generated starting from 0.21.0
Here follows an example of a received SMS via the manager interface:
Event: vgsm_sms_rx
Privilege: call,all
Received: from GSM module vodafone2, registered on 22210 (Vodafone, Italy); Wed, 20 Jun 2007 19:40:14 +0200
From: <+393471234567#sms.voismart.it>
Subject: SMS message
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: base64
Date: Wed, 20 Jun 2007 19:39:25 +0200
X-SMS-Message-Type: SMS-DELIVER
X-SMS-Sender-NP: ISDN telephony
X-SMS-Sender-TON: International
X-SMS-Sender-Number: +393471234567
X-SMS-SMCC-NP: ISDN telephony
X-SMS-SMCC-TON: International
X-SMS-SMCC-Number: +393492000429
X-SMS-More-Messages-To-Send: yes
X-SMS-Reply-Path: no
X-SMS-User-Data-Header-Indicator: no
X-SMS-Status-Report-Indication: no
Content: SG8gY2hpYW1hdG8gYWxsZSAxOTozOSBkZWwgMjAvMDYvMDcuIEluZm9ybWF6aW9uZSBncmF0dWl0YSBkZWwgc2Vydml6aW8gQ0hJQU1BTUkgZGkgVm9kYWZvbmUu
=vgsm_me_state Event=
Whenever a ME (GSM module) changes working state, an event is generated. Here is an example of such type of events:
Event: vgsm_me_state
Privilege: call,all
X-vGSM-ME-State: POWERING_OFF
X-vGSM-ME-Old-State: READY
X-vGSM-ME-State-Change-Reason: Asterisk shutdown
The currently implemented states are:
CLOSED
OFF
POWERING_ON
POWERING_OFF
RESETTING
WAITING_INITIALIZATION
INITIALIZING
READY
WAITING_SIM
WAITING_PIN
FAILED
=vgsm_net_state Event=
Whenever the registration status of a GSM module changes, a '''vgsm_net_state''' event is generated. This event is available starting from 0.21.0.
Here follows an example of such event:
Event: vgsm_net_state
Privilege: call,all
X-vGSM-GSM-Registration: REGISTERED_HOME
Valid registration states are:
* NOT_SEARCHING
* NOT_REGISTERED
* REGISTERED_HOME
* UNKNOWN
* REGISTRATION_DENIED
* REGISTERED_ROAMING

Adding Line separator (\u2028) into Logback pattern

Tried to add custom Logback pattern in order to log Exception stacktraces into a single line (where new line character is replaced with unicode Line separator \u2028), as:
%date{"yyyy-MM-dd'T'HH:mm:ss.SSSZ", UTC} %5p %t %c{5}:%L [log_framework=logback;app_name=${APP_NAME};app_version=${APP_VERSION};instance_id=${CF_INSTANCE_INDEX}] %m MULTIEXCEPTION %replace(%xException){'\n','\u2028'}%nopex%n
Note: See spring-config.xml config file in Github
In the console, \n is replaced, the Exception stacktrace is in one line but, instead with "Line separator" character (\u2028), \n is replaced with the string "u2028".
If I try to log directly this "Line separator" character (via Logback, as log message) - it is printed in the console correctly.
What could be the problem?
I've managed to do this by entering the "Line separator" unicode character (
) directly:
%date{"yyyy-MM-dd'T'HH:mm:ss.SSSZ", UTC} %5p %t %c{5}:%L [log_framework=logback;app_name=${APP_NAME};app_version=${APP_VERSION};instance_id=${CF_INSTANCE_INDEX}] %m MULTIEXCEPTION %replace(%xException){'\n','
'}%nopex%n
Note: You can also manage to make Exception stacktraces "single-lined" in Spring Boot application by adding next application property:
logging.exception-conversion-word: "%replace(%xException){'\\n','\u2028'}%nopex"

NXLog: Json input to GELF UDP Output

We have a setup where a program logs to a .Json file, in a format that follows the GELF specification.
Currently this is sent to a Graylog2 server using HTTP. This works, but due to the nature of HTTP there's a significant latency, which is an issue if there is a large amount of log messages.
I want to change the HTTP delivery method to UDP, in order to just 'fire and forget'.
The logs are written to files like this:
{ "short_message": "<message>", "host": "<host>", "full_message": "<message>", "_extraField1": "<value>", "_extraField2": "<value>", "_extraField3": "<value>" }
Current configuration is this:
<Extension json>
Module xm_json
</Extension>
<Input jsonLogs>
Module im_file
File '<File Location>'
PollInterval 5
SavePos True
ReadFromLast True
Recursive False
RenameCheck False
CloseWhenIdle True
</Input>
<Output udp>
Module om_udp
Host <IP>
Port <Port>
OutputType GELF_UDP
</Output>
With this setup, part of json log message is added to the "message" field of a GELF message, and sent to the server.
I've tried adding the line `Exec parse_json(), but this will simply result in all fields other than short_message and full_message being excluded.
I'm unsure how to configure this correctly. Even just having the complete log message added to a field is preferable, since I can add an extractor on the server side.
You'd need Exec parse_json() in order for GELF_UDP to generate proper output but it was unclear what the exact issue is with message and full/short_message.
Another option you could try is simply ship the log via om_tcp. In this case you'll not need to use OutputType GELF_TCP since it is already formatted that way.

How to generate a JSON log from nginx?

I'm trying to generate a JSON log from nginx.
I'm aware of solutions like this one but some of the fields I want to log include user generated input (like HTTP headers) which need to be escaped properly.
I'm aware of the nginx changelog entries from Oct 2011 and May 2008 that say:
*) Change: now the 0x7F-0x1F characters are escaped as \xXX in an
access_log.
*) Change: now the 0x00-0x1F, '"' and '\' characters are escaped as \xXX
in an access_log.
but this still doesn't help since \xXX is invalid in a JSON string.
I've also looked at the HttpSetMiscModule module which has a set_quote_json_str directive, but this just seems to add \x22 around the strings which doesn't help.
Any idea for other solutions to log in JSON format from nginx?
Finally it looks like we have good way to do this with vanilla nginx without any modules. Just define:
log_format json_combined escape=json
'{'
'"time_local":"$time_local",'
'"remote_addr":"$remote_addr",'
'"remote_user":"$remote_user",'
'"request":"$request",'
'"status": "$status",'
'"body_bytes_sent":"$body_bytes_sent",'
'"request_time":"$request_time",'
'"http_referrer":"$http_referer",'
'"http_user_agent":"$http_user_agent"'
'}';
Note that escape=json was added in nginx 1.11.8.
http://nginx.org/en/docs/http/ngx_http_log_module.html#log_format
You can try to use that one https://github.com/jiaz/nginx-http-json-log - addition module for Nginx.
You can try to use:
addition module for Nginx nginx-http-json-log
Use any language as done in nginx-json-logformat with example /etc/nginx/conf.d/json_log.conf
A version of the Nginx HTTP stub status module that outputs in JSON format
PS:
The if parameter (1.7.0) enables conditional logging. A request will not be logged if the condition evaluates to “0” or an empty string:
map $status $http_referer{
~\xXX 0;
default 1;
}
access_log /path/to/access.log combined if=$http_referer;
It’s a good idea to use a tool such as https://github.com/zaach/jsonlint to check your JSON data. You can test the output of your new logging format and make sure it’s real-and-proper JSON.