Welcome! Log In Create A New Profile

Advanced

http to https redirect

Posted by sachin.tiwari50 
http to https redirect
August 07, 2015 03:11AM
Hi All,

I want to run my website on https using nginx

I tried with following way
app.js
var express = require('express');
var app = express();

app.get('/', function (req, res) {
res.send('Hello World!');
});

var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;

console.log('Example app listening at http://%s:%s', host, port);
});

var express = require('express');
var app = express();

app.get('/', function (req, res) {
res.send('Hello World!');
});

var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;

console.log('Example app listening at http://%s:%s', host, port);
});

/etc/nginx/sites-enabled/localhost
server {
listen 80;

ssl_certificate /etc/apache2/ssl/apache.crt;
ssl_certificate_key /etc/apache2/ssl/apache.key;

server_name http://localhost:3000;
return 301 https://localhost:3000;
}

service nginx restart
and tried
https://locahost:80 but it is not working
Re: http to https redirect
August 07, 2015 04:03AM
sachin.tiwari50 Wrote:
-------------------------------------------------------
> listen 80;
> server_name http://localhost:3000;
> return 301 https://localhost:3000;

> https://locahost:80 but it is not working

There is no ssl listen directive so this ain't gonna work.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: http to https redirect
August 07, 2015 07:36AM
Then how should I run website on https using nginx
Re: http to https redirect
August 07, 2015 08:22AM
https://www.google.nl/#q=nginx+https+example

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: http to https redirect
August 07, 2015 12:14PM
I tried with below config
server {
listen 3000; # Where other service is listening
#listen 16000; # Where other service is listening
server_name http://54.205.97.56:3000
root /var/www/localhost/pv4azure/templates;
index index.html index.htm;

ssl on;
ssl_certificate /etc/nginx/apache.crt;
ssl_certificate_key /etc/nginx/apache.key;
return 301 https://54.205.97.56:1337;

#location / {
#proxy_pass http://localhost:3000/;
# proxy_pass http://localhost:15000/;
#}

}

https://localhost:1337/ is showing

Welcome to Nginx !!

but it is not loading the my website page
Re: http to https redirect
August 07, 2015 12:17PM
Do you have a listen directive with ssl for 'https://54.205.97.56:1337' ?

Btw. you are listening on port 3000 and sending a 301 to the client, its the client then who does redirect.

---
nginx for Windows http://nginx-win.ecsds.eu/



Edited 1 time(s). Last edit at 08/07/2015 12:20PM by itpp2012.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 133
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