Jump to content

  •  

Staff applications open!

We are looking for dedicated members to join the Community Team to help enforce the community rules and make IV a better place for everyone.
Do you think you have what it takes to join? Apply here: http://invision-viru...f-applications/
IV Management

- - - - -

Creating vaild ssl certs for nginx

linux tut

  • Please log in to reply
1 reply to this topic

#1 tamiko

tamiko

    Newbie

  • Member
  • Pip
  • 3 posts
  • LocationSpace

Posted 20 June 2019 - 08:18 PM

firstly i will be using ubuntu 18.04 for this and nignx

apt install certbot
while that is installed we can make sure we have a basic node server running just to see our https connection is connecting right.

apt install nodejs npm

mkdir nodesite
cd nodesite
npm init -y
npm i -S express

the above we are creating our environment

create a file name app.js fill the file with the following
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

then we can install a process manager to start our node server npm i -g pm2 after that is installed we can go and start the server with pm2 start app.js

now we can install nginx with apt install nginx create a file in /etc/nginx/sites-available/site.conf
fill this file with the following since we are creating a reverse proxy to serve out node server.

server {
listen 80;
server_name invisionvirus.com www.invisionvirus.com;
location / {
	 proxy_pass http://127.0.0.1:8080;
	 proxy_http_version 1.1;
	 proxy_set_header Upgrade $http_upgrade;
	 proxy_set_header Connection 'upgrade';
	 proxy_set_header Host $host;
	 proxy_cache_bypass $http_upgrade;
	 }
}

then start the webserver with
systemctl enable nginx #this will enable on boot
systemctl start nginx # this will start the server

then we have to enable the file with
ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/
check for errors with nginx -t

and now we can create a valid cert with certbot with certbot -d invisionvirus.com -d www.invisionvirus.com

and we are done!

#2 [email protected]

[email protected]

    Newbie

  • Member
  • Pip
  • 5 posts

Posted 22 June 2019 - 05:19 PM

create a file name app.js fill the file with the following
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

const port = 3000 will not work in as you need iptables services to be stop when you are doing ssl setup

first of all shut iptables then restart when ssl setup is done.





Also tagged with one or more of these keywords: linux, tut

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users