26 September 2021

Nginx config proxy_pass

 

Nginx config
2021
worker_processes 4;

events {
  worker_connections  1024;
}

http {
    upstream backends {
        server 10.32.35.20:89;
    }
    server {
      listen 80;
      server_name  localhost;

      root   /usr/share/nginx/html;
      index  index.html index.htm;
      include /etc/nginx/mime.types;

      access_log  /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;

      gzip on;
      gzip_min_length 1000;
      gzip_proxied expired no-cache no-store private auth;
      gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;

      location ~ \.css {
        add_header  Content-Type    text/css;
      }

      location ~ \.js {
        add_header  Content-Type    application/x-javascript;
      }

      location /api {
        set $backend_servers domain.api.vn;
        rewrite ^\/api\/(.*)$ /api/$1 break;
        proxy_pass http://$backend_servers:88;
      }
      location / {
        try_files $uri$args $uri $uri/ /index.html =404;
      }
  }
}


0 nhận xét:

Post a Comment

 

BACK TO TOP

Xuống cuối trang