location = /monit { return 301 https://$host/monit/; } location /monit/ { rewrite ^/monit/(.*) /$1 break; proxy_ignore_client_abort on; proxy_pass http://127.0.0.1:2812; proxy_redirect / /monit/; proxy_cookie_path / /monit/; proxy_set_header Host $host; }