To set up your Frontend server start with launching a new EC2 instance:
Configure Security Group, add public access for 80 and 443 ports and provide access to the internal networks
Point your domain to this Elastic IP
Then, connect to Bastion server and to Frontend Server via SSH.
On the Frontend server you would need to setup the Nginx.
apt update
apt upgrade -y
apt install nginx -y
</span> apt update apt upgrade -y apt install nginx -y <span style="font-weight: 400;">
edit /etc/nginx/proxy_params
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for
</span> <span style="font-weight: 400;">edit /etc/nginx/proxy_params</span><span style="font-weight: 400;"> </span><span style="font-weight: 400;">proxy_set_header X-Forwarded-Host $host:$server_port;</span> <span style="font-weight: 400;">proxy_set_header X-Forwarded-Server $host;</span> <span style="font-weight: 400;">proxy_set_header Host $host;</span> <span style="font-weight: 400;">proxy_set_header X-Real-IP $remote_addr;</span> <span style="font-weight: 400;">proxy_set_header X-Forwarded-For </span> <span style="font-weight: 400;">$proxy_add_x_forwarded_for</span> <span style="font-weight: 400;">
server {
listen 80;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2 default_server;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_ciphers ‘EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH’;
ssl_protocols TLSv1.2 TLSv1.3;
location /api/ {
include proxy_params;
proxy_pass https://app:8443/api/v1/;
}
location /api/v1/ {
include proxy_params;
proxy_pass https://app:8443/api/v1/;
}
location /swagger/ {
include proxy_params;
proxy_pass https://swagger:443/swagger/;
}
location / {
root /var/www;
try_files $uri $uri/ /index.html last;
}
}
</span> <ul> <li style="font-weight: 400;" aria-level="1"><span style="font-weight: 400;">edit /etc/nginx/sites-enabled/default </span></li> </ul> <span style="font-weight: 400;">server {</span> <span style="font-weight: 400;"> listen 80;</span> <span style="font-weight: 400;"> return 301 https://$host$request_uri;</span> <span style="font-weight: 400;">}</span> <span style="font-weight: 400;">server {</span> <span style="font-weight: 400;"> listen 443 ssl http2 default_server;</span> <span style="font-weight: 400;"> ssl_certificate /etc/nginx/ssl/server.crt;</span> <span style="font-weight: 400;"> ssl_certificate_key /etc/nginx/ssl/server.key;</span> <span style="font-weight: 400;"> ssl_ciphers ‘EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH’;</span> <span style="font-weight: 400;"> ssl_protocols TLSv1.2 TLSv1.3;</span> <span style="font-weight: 400;"> location /api/ {</span> <span style="font-weight: 400;"> include proxy_params;</span> <span style="font-weight: 400;"> proxy_pass https://app:8443/api/v1/;</span> <span style="font-weight: 400;"> }</span> <span style="font-weight: 400;"> location /api/v1/ {</span> <span style="font-weight: 400;"> include proxy_params;</span> <span style="font-weight: 400;"> proxy_pass https://app:8443/api/v1/;</span> <span style="font-weight: 400;"> }</span> <span style="font-weight: 400;"> location /swagger/ {</span> <span style="font-weight: 400;"> include proxy_params;</span> <span style="font-weight: 400;"> proxy_pass https://swagger:443/swagger/;</span> <span style="font-weight: 400;"> }</span> <span style="font-weight: 400;"> location / {</span> <span style="font-weight: 400;"> root /var/www;</span> <span style="font-weight: 400;"> try_files $uri $uri/ /index.html last;</span> <span style="font-weight: 400;"> }</span> <span style="font-weight: 400;">}</span> <span style="font-weight: 400;">
/etc/nginx/ssl/server.crt
</span> /etc/nginx/ssl/server.crt <span style="font-weight: 400;">
/etc/nginx/ssl/server.crt
</span> /etc/nginx/ssl/server.crt <span style="font-weight: 400;">
service nginx restart
</span> service nginx restart <span style="font-weight: 400;">
Upload your frontend to this folder: /var/www/
Next