Yii 1.1: Yii behind a reverse proxy, SSL support and correct IP logging


If you are hosting Yii behind a reverse proxy, for example nginx, and you are having issues with your logs showing the proxies IP, or the urls being created arn't being created for SSL because your SSL certs are located on your reverse proxy instead of the Yii server, this code may be able to help you. I placed them in the very top of Yii's entry script, index.php

$_SERVER['HTTPS'] = 'on';

Make sure your reverse proxy added the HTTP_X_REAL_IP header to the request. There is much documentation on this all over the web.

Be the first person to leave a comment

Please to leave your comment.

Write new article
  • Written by: mrkmg
  • Category: Tips
  • Yii Version: 1.1
  • Votes: -1
  • Viewed: 6,975 times
  • Created on: Jul 30, 2012
  • Last updated: never
  • Tags: ssl, reverse proxy