Задать вопрос
Ответы пользователя по тегу Node.js
  • Как настроить проксирование в nginx нескольких приложений?

    devpav
    @devpav
    Full-Stack разработчик.
    Привет.

    5d8b1ce6b9047946336749.png

    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    events {
           worker_connections  1024;
    }
    
    http {
          include       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  logs/access.log  main;
    
          sendfile        on;
          #tcp_nopush     on;
    
          #keepalive_timeout  0;
          keepalive_timeout  65;
          send_timeout 300;
          proxy_read_timeout 300;
          proxy_connect_timeout 300;
    
          gzip  on;
          gzip_vary on;
          gzip_min_length 10240;
          gzip_proxied expired no-cache no-store private auth;
          gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/json;
    
          server {
            listen 80;
    
            if ($scheme = https) {
                return 301 http://$host$request_uri;
            }
          }
    
          server {
                listen 80;
    
                server_name localhost ************ 127.0.0.1;
    
                add_header Last-Modified $date_gmt;
                add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
                if_modified_since off;
                expires off;
                etag off;
    
                location / {
                   root /usr/share/nginx/html/;
                   index index.html;
                }
    
                location /api {
                    proxy_pass http://rest:8080/api;
                    proxy_set_header Host $host:$server_port;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-for $remote_addr;
                    proxy_redirect off;
                }
          }
    }


    Прочти:
    nginx.org/ru/docs/beginners_guide.html
    Ответ написан
    Комментировать