Improve nginx rewriting