Varnish, Nginx e SSL help

June 17, 2014 1.8k views
Hi! I have a droplet running nginx, varnish and Wordpress and it's working fine. I decided then to install a certificate and setup to whole thing to allow me to run the wordpress blog on https. I know I have to do the redirection from http to https, but when I add the lines bellow nginx fails to start, because it's using the same 80 port.
server { 
listen 80 default_server; 
return 301 https://$host$request_uri; 
server_name myIPAdress; 
I am newbie on this and even having learned a lot, I am not sure how to fix this. I even saw the question bellow too and asked a question, because apparently, the user is running exaxctly the wat I should too. Can someone help? Thks!
1 Answer
This article is the best thing that I've found on the topic: Essentially, you'll need to set up Varnish to listen on port 80 and use an Nginx backend listening on something else like port 8000 in this example. Nginx will then listen directly on 443 for https requests and then proxy them to port 80 on the local host for Varnish.
Have another answer? Share your knowledge.