Ankit Makadiya
Ankit Makadiya

Reputation: 51

How can I run node js and apache with single ssl certificate with different port?

I am using nodejs on port number 3000 and my site is ssl-certified. After running node server.js I got below error:

GET https://--.---.-.---:3000/socket.io/?EIO=3&transport=polling&t=1513323461271-0 net::ERR_CONNECTION_REFUSED.

So, how can I run node js and apache with single ssl certificate with different port? And my site is hosted on Amazon Server.

Upvotes: 3

Views: 470

Answers (1)

Anandan K
Anandan K

Reputation: 1438

Hope you already configured SSL in Apache

Node(Express)

const express = require('express');
const app = express();
var cors = require('cors')
app.use(cors());
var server = require('http').createServer(app);

Open httpd.conf in server and add ProxyPass line as u want

ProxyPass /api/ http://localhost:3000/

DONT FOGOT TO RESTART THE HTTP SERVICE

http://www.example.com/mypage apache http: OK!

https://www.example.com/mypage apache https: OK!

http://www.example.com/api/ node http: OK!

https://www.example.com/api/ node https: IT WORKKS !!!

Upvotes: 4

Related Questions