Add Nginx Rewrite Rules to your application

How to add rewrite rules in Nginx

NOTE: We’re working on a configuration panel so that you can edit your configs right from Moss. In the meantime, you must follow the guidelines in this article.

In case your application requires Nginx to rewrite some URLs, in this article you’ll find how to make it work. As an example, we’ll add a simple rewrite rule taken from Nginx documentation to a site called site.

Take a quick look first to the basics about fine-tuning your applications with Moss in case you haven’t done it yet.

Nginx configuration

  1. Log into your server as user moss: ssh moss@<server-ip> 
  2. Using sudo and your favorite text editor, add as many rewrite rules as you need to file /etc/openresty/ E.g:
rewrite ^/users/(.*)$ /show?user=$1? last;

3. Restart Nginx from the Software tab