在nginx.conf文件中,是否可以根据当前连接是否安全重写为HTTP或HTTPS?
一些我想要做的伪代码。
location ^~ /test_api { if (secured connection) rewrite "/test_api" https://www.somedomain.com/test_api break; else rewrite "/test_api" http://www.somedomain.com/test_api break; }
谢谢。
你正在寻找$scheme 。
rewrite /test_api $scheme://www.example.com/test_api break;