Skip to content

Comments

Exporting error (4xx/5xx) entries to Nginx config#2669

Open
EvanK wants to merge 4 commits intojohngodley:trunkfrom
EvanK:nginx-export-errors
Open

Exporting error (4xx/5xx) entries to Nginx config#2669
EvanK wants to merge 4 commits intojohngodley:trunkfrom
EvanK:nginx-export-errors

Conversation

@EvanK
Copy link

@EvanK EvanK commented Dec 25, 2020

Error code redirects (eg, a 410 to "kill" a url for SEO purposes or a 451 for legal takedowns) are not correctly exported in the nginx format, which this PR aims to fix.

Example data

Given this set of examples (a single redirect, the rest are error codes):

Screen Shot 2020-12-24 at 2 49 51 PM

What happens now

They're currently exported as rewrite directives without a target, all of which will effectively 404:

Screen Shot 2020-12-24 at 3 54 38 PM

Ideal output

Instead, a location block returning the error code seems to do the trick:

Screen Shot 2020-12-24 at 3 54 58 PM

Note that, for non-regex entries tagged with case insensitivity, the easiest way to accomplish that was to use it as an (escaped) regex with a case insensitive modifier (~*). Any other non-regex can use the exact match modifier (=).

Loose ends

I've added some tests for these cases, but was unable to run them locally to verify ahead of time. 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant