Welcome! Log In Create A New Profile

Advanced

http and https on same server

Posted by sumitsrjhs 
http and https on same server
May 04, 2015 01:16AM
Hi

I am running nginx as proxy and both of http and https requests are going from same server.
While opening web site request goes to http by default. how can i change it to https ?

Regards
Re: http and https on same server
May 04, 2015 02:35AM
server {
listen 80;
server_name www.domain.nl;
return 301 https://www.domain.nl$request_uri;
}

server {
listen 443;
server_name www.domain.nl;
[...]
}

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: http and https on same server
May 04, 2015 02:42AM
My config is

server
{
listen 80;
server_name MyTest;
index index.htm;
location /{
proxy_pass http://x.x.x.x;
...
}

server
{
listen 443 default ssl;
ssl on;
server_name test.in;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate ssl/test.crt;
ssl_certificate_key ssl/test.key;
location /{
proxy_pass https://x.x.x.x;
...
...
}

Where does it fits ??

Regards
Re: http and https on same server
May 04, 2015 03:51AM
What do you want to happen?

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: http and https on same server
May 04, 2015 04:46AM
Hi

my nginx server is serving for two websites, 1 is http and 2nd is https. While accessing through nginx it goes to http by default, for https i have to put https. i want to access https by default by nginx.

Regards
Re: http and https on same server
May 04, 2015 04:54AM
Some reading material;

http://serverfault.com/questions/578648/properly-setting-up-a-default-nginx-server-for-https
http://forum.nginx.org/read.php?2,229949,229949#msg-229949
https://tech.mendix.com/linux/2014/10/29/nginx-certs-sni/

It more or less depends what type of clients connect, SNI support and how you define the first server block.

---
nginx for Windows http://nginx-win.ecsds.eu/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 173
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready