SERA integration on Apache¶
Kindly follow the below examples to setup the routing of bot traffic to SERA.
- Change YOUR_TOKEN to the SERA token shared with you
- Change example.com (server_name) to your actual domain
- Change /path/to/your/root to the correct value
- Keep the relevant bot user-agent regex condition mentioned below - to control the traffic being sent to SERA
LoadModule dir_module modules/mod_dir.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule headers_module modules/mod_headers.so
LoadModule ssl_module modules/mod_ssl.so
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /path/to/your/root/
<Directory "/path/to/your/root/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
RewriteEngine On
<IfModule mod_headers.c>
RequestHeader set x-nv-sera-token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_proxy_http.c>
#USE THIS RewriteCond - DURING POC PHASE for bot User-Agent check :
RewriteCond %{HTTP_USER_AGENT} (n7TestUserAgent|PTST|GTmetrix) [NC,OR]
#USE THIS RewriteCond - ON GOING LIVE ON SERA for bot User-Agent check :
RewriteCond %{HTTP_USER_AGENT} (googlebot|google\\ page\\ speed|chrome-lighthouse|google-inspectiontool|PTST|GTmetrix) [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
RewriteCond %{HTTP_X_NV_APP} ^$
RewriteCond %{HTTP_X_NV_SERA_BYPASS} ^$
RewriteCond %{REQUEST_URI} !(\.ai|\.ashx|\.asmx|\.aspx|\.avi|\.avif|\.bmp|\.css|\.csv|\.dat|\.dmg|\.doc|\.eot|\.exe|\.flv|\.gif|\.ico|\.iso|\.jpeg|\.jpg|\.js|\.json|\.jsp|\.less|\.m4a|\.m4v|\.mov|\.mp3|\.mp4|\.mpeg|\.mpg|\.ogg|\.otf|\.pdf|\.php|\.png|\.ppt|\.psd|\.rar|\.rss|\.svg|\.swf|\.tif|\.torrent|\.ttf|\.txt|\.wav|\.webm|\.webp|\.wmv|\.woff|\.woff2|\.xls|\.xml|\.zip) [NC]
RewriteRule (.*) https://sera.n7.io/$2 [P,END]
</IfModule>
</IfModule>
</VirtualHost>
Testing and Refinement¶
- You can test the Apache configuration on Fiddle
- Keep refining the logic by adjusting user-agent list, and SERA exclusion-patterns as needed.
- Test thoroughly:
- WPT and GTMetrix will automatically receive the response from SERA due to the routing rule set above.
- Steps to validate page using WPT
- To check the SERA rendered page on browser, you can use some browser extension (like Simple modify headers) to manipulate the browser user-agent. If in testing phase, use these user-agent values: For desktop: For mobile: If SERA is live, you can use these actual bot user-agent values: For desktop: For mobile:
- WPT and GTMetrix will automatically receive the response from SERA due to the routing rule set above.
- On go-live day, set the user-agent condition regex to actual bot user-agent values. Additionally, ensure that your condition is case-insensitive.