From cf048d512059900d2f86bd33c98d16757670988e Mon Sep 17 00:00:00 2001
From: Anton Sarukhanov <code@ant.sr>
Date: Wed, 26 Aug 2020 10:19:50 -0400
Subject: [PATCH] Add URL shortener to Nginx config.

---
 nginx.conf | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/nginx.conf b/nginx.conf
index 01b2673..3ba1a47 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -1,5 +1,6 @@
 server {
     listen 80;
+    recursive_error_pages on;
     location / {
         root /opt/ant.sr/html;
         error_page 404 = @files;
@@ -9,7 +10,14 @@ server {
         error_page 404 = @urlshortener;
     }
     location @urlshortener {
-        # TODO!
-        return 404;
+        proxy_pass http://kutt.antsr.svc.cluster.local:3000;
+        proxy_intercept_errors on;
+        proxy_set_header Host      ant.sr;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Forwarded-for $remote_addr;
+        error_page 404 = @notfound;
     }
+    location @notfound {
+        return 404 "Sorry, not found!";
+   }
 }
-- 
GitLab