I have a config file with a virtual server setup, this is running on port 443 for ssl. I would also like this same virtual server to handle non ssl traffic on port 80.
I was hoping to do the following but it doesn't seem to work.
server { listen 443 ssl; listen 80; server_name example.com; ... }
It looks like the ssl options below these settings are causing problems for the non ssl traffic.
To make Nginx Listen on multiple ports for a single virtual host file, you can add multiple listen directives. If you want to make Nginx listen for different virtual hosts on different ports, you can use different ports in listen directive in different virtual host files. It's that easy!
Setting up an HTTPS Server. To set up an HTTPS server, in your nginx. conf file include the ssl parameter to the listen directive in the server block, then specify the locations of the server certificate and private key files: server { listen 443 ssl; server_name www.example.com; ssl_certificate www.
Turns out it is possible to have both HTTP and HTTPS servers and choose HTTPS by default. I just had to mix the two servers of the conf file in one, just like: server { listen 80; listen 443 default_server ssl; ssl_certificate certificate. crt; ssl_certificate_key server.
Yes, of course.
server { listen 80; listen 443 ssl; # force https-redirects if ($scheme = http) { return 301 https://$server_name$request_uri; } }
Here is my post, name "Nginx Configuration for HTTPS" which contains more info.
Remove ssl on;
directive.
ssl
flag in listen
directive is exactly what you need.
See http://nginx.org/en/docs/http/configuring_https_servers.html#single_http_https_server
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With