Skip to content

Instantly share code, notes, and snippets.

@hoangmirs
Last active February 16, 2023 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoangmirs/578909c5ffa4e1530ed03ece1b12c35c to your computer and use it in GitHub Desktop.
Save hoangmirs/578909c5ffa4e1530ed03ece1b12c35c to your computer and use it in GitHub Desktop.
NGINX config files
# For nuxt or next app with node server running on 8000
server {
listen 80;
server_name 212.83.163.175;
server_name #domain name;
root /home/deploy/app;
access_log /home/deploy/app/logs/nginx_access.log;
error_log /home/deploy/app/logs/nginx_error.log;
try_files $uri $uri/ /index.html;
location / {
proxy_pass http://localhost:8000;
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;
}
}
# For RAILS app
upstream app {
# Path to Puma SOCK file, as defined previously
server unix:/home/deploy/app/shared/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 3333;
server_name #domain name;
root /usr/local/rails_apps/project_name/current/public;
access_log /usr/local/rails_apps/project_name/current/log/nginx_access.log;
error_log /usr/local/rails_apps/project_name/current/log/nginx_error.log;
try_files $uri/index.html $uri @app;
location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_redirect off;
proxy_set_header Connection '';
proxy_pass http://app;
proxy_http_version 1.1;
}
location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {
gzip_static on;
expires max;
add_header Cache-Control public;
}
client_max_body_size 4G;
keepalive_timeout 10;
}
# For static resource
server {
listen 80;
server_name 212.83.163.175;
server_name #domain name;
root /home/deploy/app/dist;
access_log /home/deploy/app/logs/nginx_access.log;
error_log /home/deploy/app/logs/nginx_error.log;
try_files $uri $uri/ /index.html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment