F5 XC vk8s open source nginx deployment on RE
Code is community submitted, community supported, and recognized as ‘Use At Your Own Risk’.
Short Description
This an example for F5 XC virtual kubernetes (vk8s) workload on Regional Edges for rewriting the URL requests and response body.
Problem solved by this Code Snippet
The XC Distributed Cloud rewrite option under the XC routes is sometimes limited in dynamically replacing a specific sting like for example to replace the string "ne" with "da" no matter where in the url the string is located.
location ~ .*ne.* {
rewrite ^(.*)ne(.*) $1da$2;
}
Other than that in XC there is no default option to replace a string in the payload like rewrite profile in F5 LTM or iRule stream option.
sub_filter 'Example' 'NIKI';
sub_filter_types *;
sub_filter_once off;
Open source NGINX can also be used to return custom error based on the server error as well:
error_page 404 /custom_404.html;
location = /custom_404.html {
return 404 'gangnam style!';
internal;
}
Now with proxy protocol support in XC the Nginx can see real client ip even for non-HTTP traffic that does not have XFF HTTP headers.
log_format niki '$proxy_protocol_addr - $remote_addr - $remote_user [$time_local] - $proxy_add_x_forwarded_for'
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
#limit_req_zone $binary_remote_addr zone=mylimit:10m rate=1r/s;
server {
listen 8080 proxy_protocol;
server_name localhost;
How to use this Code Snippet
Read the description readme file in the github link and modify the nginx default.conf file as per your needs.
Code Snippet Meta Information
- Version: 1.25.4 Nginx
- Coding Language: nginx config
Full Code Snippet
https://github.com/Nikoolayy1/xc_nginx/tree/main
Also the open source NGINX can be used to return custom error based on the server error 😉
error_page 404 /custom_404.html;
location = /custom_404.html {
return 404 'gangnam style!';
internal;
}Why do I feel like listening to K-Pop now?
🕺F5 style ! I still remember the clip 😀