88 lines
2.3 KiB
Nginx Configuration File
88 lines
2.3 KiB
Nginx Configuration File
# ============================================================
|
|
# Global Settings
|
|
# ============================================================
|
|
|
|
user www-data;
|
|
worker_processes auto;
|
|
pid /run/nginx.pid;
|
|
include /etc/nginx/modules-enabled/*.conf;
|
|
|
|
# ============================================================
|
|
# Events Block
|
|
# ============================================================
|
|
events {
|
|
worker_connections 1024;
|
|
use epoll;
|
|
multi_accept on;
|
|
}
|
|
|
|
# ============================================================
|
|
# HTTP Block
|
|
# ============================================================
|
|
http {
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
# Logging
|
|
access_log /var/log/nginx/access.log;
|
|
error_log /var/log/nginx/error.log warn;
|
|
|
|
# Gzip Settings
|
|
gzip on;
|
|
gzip_disable "msie6";
|
|
|
|
# ========================================================
|
|
# Upstream Backend Servers
|
|
# ========================================================
|
|
upstream backend {
|
|
server 127.0.0.1:8080 weight=5;
|
|
server 127.0.0.1:8081;
|
|
keepalive 32;
|
|
}
|
|
|
|
# ========================================================
|
|
# Server Block
|
|
# ========================================================
|
|
server {
|
|
listen 80 default_server;
|
|
listen [::]:80 default_server;
|
|
|
|
server_name example.com www.example.com;
|
|
|
|
root /var/www/html;
|
|
index index.html index.htm;
|
|
|
|
# ====================================================
|
|
# Location Blocks
|
|
# ====================================================
|
|
location / {
|
|
try_files $uri $uri/ =404;
|
|
}
|
|
|
|
location /api/ {
|
|
proxy_pass http://backend;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
|
|
location ~* \.(gif|jpg|jpeg|png|css|js|ico|svg)$ {
|
|
expires 30d;
|
|
add_header Cache-Control "public, no-transform";
|
|
}
|
|
|
|
error_page 404 /404.html;
|
|
error_page 500 502 503 504 /50x.html;
|
|
|
|
location = /50x.html {
|
|
root /var/www/html;
|
|
}
|
|
}
|
|
}
|