If you have faced this problem with your AEM/CQ5 environment that each time you hit via a webserver or you hit your application via IP address directly you are always being redirected to login page
To solve the issue, Check the following things
1. Any Repository Policy nodes that have security settings specified at the root level (/) which can restrict anonymous access.
2. If anonymous user has appropriate ACL’s assigned on the node being accessed and redirected to in case applicable.
3. Check and see in your publish environment (http://localhost:4503/system/console/configMgr) if you have enabled anonymous access to user in Apache Sling Authentication Service. There is a checkbox, just check that.
These are some of the possible causes of user being redirected to login page. Would like to hear from the community in case anybody else also solved their problem with other solutions.