Press "Enter" to skip to content

Deploy MERN STACK App with AWS EC2



git repo: https://github.com/jaewonhimnae/deploy-mern-aws-ec2

Nginx Configuration

/etc/nginx/nginx.conf

user ubuntu;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

client_body_buffer_size 100k;
client_header_buffer_size 1k;
client_max_body_size 100k;
large_client_header_buffers 2 1k;
client_body_timeout 10;
client_header_timeout 10;
keepalive_timeout 5 5;
send_timeout 10;
server_tokens off;
#gzip on; on;

include /etc/nginx/conf.d/*.conf;
}

/etc/nginx/conf.d/default.conf

server {
#listen 80;
listen 80 default_server;
listen [::]:80 default_server;
server_name yourdomain.com;

access_log /home/ubuntu/client/server_logs/host.access.log main;

location / {
root /home/ubuntu/client/deploy;
index index.html index.htm;
try_files $uri /index.html;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection “1; mode=block”;
add_header Strict-Transport-Security “max-age=31536000; includeSubdomains;”;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

server_tokens off;

location ~ /.ht {
deny all;
}

}

11
Leave a Reply

avatar
11 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
0 Comment authors
Chandra wadudOptimusBananaDoxxMohd ShoyebJack RongSaumya Mani Tripathi Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Nelson
Guest
Nelson

What’s the vscode themes u use

Abi Akhil
Guest
Abi Akhil

Please do tutorial formik.User form.

Victoria'a Timberlake
Guest
Victoria'a Timberlake

Thanks John for this awesome video.

I have an issue with uploading pictures on the application when successfully uploaded on heroku.

It works well on my local host but not on heroku

Saumya Mani Tripathi
Guest
Saumya Mani Tripathi

Awesome sir thanks for the videos….

Jack Polo
Guest
Jack Polo

I got 504 gateway timeout on AWS EC2 when POST and GET requests, any idea what is causing this?

Daniel JING
Guest
Daniel JING

thanks a lot for your educational video, I think it's more better than others even though there are a lot of videos like this. But I think you are the best. hope you get more follower and I appreciate that.

Jack Rong
Guest
Jack Rong

If possible, I would also want to know the part you did not explain. That is how to download and config the MongoDB in the EC2 instead of using MongoAtlas. Please~~~ So happy to learn a lot from here. ^_^. Thanks John.

Mohd Shoyeb
Guest
Mohd Shoyeb

Very nice video, Thanks you so much.

Jack Rong
Guest
Jack Rong

Nice video, nice diagrams to explain. Thanks, bro.

OptimusBananaDoxx
Guest
OptimusBananaDoxx

new video yaaay

Chandra wadud
Guest
Chandra wadud

Hello sir can you make auth crud pagination with react and aws serverless