-
Notifications
You must be signed in to change notification settings - Fork 0
/
server commands.txt
187 lines (127 loc) · 3.65 KB
/
server commands.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
created ec2 instance
ubuntu 22.04
8 GB space
sudo apt update
sudo apt upgrade
apt install nginx -y
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install nodejs -y
node -v
sudo apt-get install gcc g++ make
apt install build-essential -y
cd /var/www/html
nano index.js
////////////////////
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
}).listen(3000);
/////////////////////
nano /etc/nginx/sites-available/default
/////////////////////
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
////////////////////
sudo ufw app list
sudo ufw status
sudo ufw allow OpenSSH
sufo ufw enable
sudo ufw allow 'Nginx HTTP'
sudo ufw enable
sudo systemctl enable nginx
sudo ufw status
//Route 53
4 DNS record to bigrock domain added
IP of EC2
create another record as alias (www) and select A (nftarena.in)
sudo mkdir -p /var/www/nftarena.in/html
sudo chown -R $USER:$USER /var/www/nftarena.in/html
sudo chmod -R 755 /var/www/nftarena.in
nano /var/www/nftarena.in/html/index.html
///////////
<html>
<head>
<title>Welcome to your_domain!</title>
</head>
<body>
<h1>Success! nftarena.in is working!</h1>
</body>
</html>
////////////
sudo nano /etc/nginx/sites-available/nftarena.in
/////////////
server {
listen 80;
listen [::]:80;
root /var/www/nftarena.in/html;
index index.html index.htm index.nginx-debian.html;
server_name nftarena.in www.nftarena.in;
location / {
try_files $uri $uri/ =404;
}
}
//////////////////
sudo ln -s /etc/nginx/sites-available/nftarena.in /etc/nginx/sites-enabled/
sudo nginx -t
//HTTPS
sudo snap install core; sudo snap refresh core
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo nginx -t
sudo systemctl reload nginx
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
sudo certbot --nginx -d nftarena.in -d www.nftarena.in
email-id
sudo systemctl status snap.certbot.renew.service
sudo certbot renew --dry-run
nano hello.js
/////////////////
const http = require('http');
const hostname = 'localhost';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World!\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
///////////////////////
node hello.js
sudo nano /etc/nginx/sites-available/nftarena.in
////////////////// inside location/
proxy_pass http://localhost:3000;
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;
//////////////
sudo nginx -t
sudo systemctl reload nginx
sudo npm install pm2@latest -g
pm2 start hello.js
// pm2 startup systemd
// <follow>
pm2 stop app_name_or_id (default 0)
pm2 list
git clone https://github.com/muhammadfarhankt/NFT_Arena.git
npm install
create .env
pm2 start index.js