Skip to content

Instantly share code, notes, and snippets.

@noherczeg
Last active June 27, 2023 15:56
Show Gist options
  • Select an option

  • Save noherczeg/f9293abfe0b78198b68e to your computer and use it in GitHub Desktop.

Select an option

Save noherczeg/f9293abfe0b78198b68e to your computer and use it in GitHub Desktop.
Sample nginx configuration for an angular frontend
worker_processes 4;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
upstream backend {
server 127.0.0.3:8080;
}
# APP configuration
server {
charset UTF-8;
listen 127.0.0.2:80;
server_name $app_domain;
location ~ /\. {
deny all;
}
# frontend
location / {
root /opt/work/app/app/app-client/;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# backend
location /api/ {
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-NginX-Proxy true;
proxy_pass http://backend/api/;
proxy_pass_header Set-Cookie;
proxy_cookie_domain app.dev 127.0.0.3;
proxy_read_timeout 60s;
proxy_redirect off;
proxy_ssl_session_reuse off;
proxy_http_version 1.1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment