0

I am writing a NodeJs application. I need to secure(https) only the login page. Home page should be non-secure(http).

If my domain is www.example.com,

If a http://www.example.com request come it should be redirect to https://www.example.com (secure https)

After user successfully login to the system it should go to the http://www.example.com/home url. not the https://www.example.com/home

When user login out it should be redirect to https://www.example.com (secure https)

Please give me some help for achieve this. or If you have come a cross this king of live situation please let me know.

Dinusha
  • 696
  • 1
  • 14
  • 27

1 Answers1

1

I would recommend setting up a web server in front of your node app such as nginx or Apache. With nginx for example, you can do a ProxyPass as outlined as in this answer: https://stackoverflow.com/a/10375750/760297

You can then add rules to redirect people to HTTPS or HTTP based on their current path via server configurations and keep your app all one protocol. This reduces the overhead on node and your development.

Community
  • 1
  • 1
SamT
  • 10,374
  • 2
  • 31
  • 39