2017-03-29 8 views
0

Mein Projekt ist Javascript App. Ich habe viele Abhängigkeiten. I/O für npm Registrierung nimmt einen Großteil der CI-Ausführung. Also meine Idee ist die Einrichtung NGINX vor npm Registry und Cache tgz-Dateien zum Download. Ich laufe Ubuntu 14.04. NGINX Version ist 1.4.6Einlösen Pakete für npm Registrierung mit NGINX

Das ist mein nginx Konfigurationsskript

user www-data; 
worker_processes 4; 
pid /run/nginx.pid; 

events { 
    worker_connections 768; 
    # multi_accept on; 
} 

http { 

    ## 
    # Basic Settings 
    ## 

    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 
    keepalive_timeout 65; 
    types_hash_max_size 2048; 
    # server_tokens off; 

    # server_names_hash_bucket_size 64; 
    # server_name_in_redirect off; 

    include /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    ## 
    # Logging Settings 
    ## 

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

    ## 
    # Gzip Settings 
    ## 

    gzip on; 
    gzip_disable "msie6"; 

    include /etc/nginx/conf.d/*.conf; 
    # include /etc/nginx/sites-enabled/*; 
    # HTTP 1.1 support 
    proxy_http_version 1.1; 
    proxy_buffering off; 
    proxy_set_header Host $http_host; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection $proxy_connection; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; 
    proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl; 
    proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port; 

    # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the 
    # scheme used to connect to this server 
    map $http_x_forwarded_proto $proxy_x_forwarded_proto { 
     default $http_x_forwarded_proto; 
     ''  $scheme; 
    } 

    # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the 
    # server port the client connected to 
    map $http_x_forwarded_port $proxy_x_forwarded_port { 
     default $http_x_forwarded_port; 
     ''  $server_port; 
    } 

    # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any 
    # Connection header that may have been passed to this server 
    map $http_upgrade $proxy_connection { 
     default upgrade; 
     '' close; 
    } 

    # Set appropriate X-Forwarded-Ssl header 
    map $scheme $proxy_x_forwarded_ssl { 
     default off; 
     https on; 
    } 

    server { 
     listen 80 default_server; 

     location/{ 
      access_log /var/log/nginx/root.log; 
      root  /var/tmp/nginx/npm; 
      try_files $request_uri @fetch; 
     } 

     location @fetch { 
       internal; 
       proxy_pass    http://nmregistry:4873$request_uri; 
       proxy_store    /var/tmp/nginx/npm$request_uri; 
       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_store_access  user:rw group:rw all:r;     
     } 
    } 
} 

Es funktioniert, ich Pakete installieren, aber sie sind nicht auf NGINX Maschine zwischengespeichert. Kann keine tgz Dateien in/var/tmp/nginx/npm sehen

Was mache ich hier falsch?

Antwort

0

Dies ist Endfassung Konfigurationsdatei. Das Hauptproblem war proxy_buffering auf;

user www-data; 
worker_processes 4; 
pid /run/nginx.pid; 

events { 
    worker_connections 768; 
} 

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 Settings 
    ## 

    error_log /var/log/nginx/error.logi debug; 

    ## 
    # Gzip Settings 
    ## 

    gzip on; 
    gzip_disable "msie6"; 

    include /etc/nginx/conf.d/*.conf; 
    # include /etc/nginx/sites-enabled/*; 
    # HTTP 1.1 support 
    proxy_http_version 1.1; 
    proxy_buffering on; 
    proxy_set_header Host $http_host; 
    proxy_set_header Upgrade $http_upgrade; 
    proxy_set_header Connection $proxy_connection; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto; 
    proxy_set_header X-Forwarded-Ssl $proxy_x_forwarded_ssl; 
    proxy_set_header X-Forwarded-Port $proxy_x_forwarded_port; 

    # If we receive X-Forwarded-Proto, pass it through; otherwise, pass along the 
    # scheme used to connect to this server 
    map $http_x_forwarded_proto $proxy_x_forwarded_proto { 
    default $http_x_forwarded_proto; 
    ''  $scheme; 
    } 

    # If we receive X-Forwarded-Port, pass it through; otherwise, pass along the 
    # server port the client connected to 
    map $http_x_forwarded_port $proxy_x_forwarded_port { 
    default $http_x_forwarded_port; 
    ''  $server_port; 
    } 

    # If we receive Upgrade, set Connection to "upgrade"; otherwise, delete any 
    # Connection header that may have been passed to this server 
    map $http_upgrade $proxy_connection { 
    default upgrade; 
    '' close; 
    } 

    # Set appropriate X-Forwarded-Ssl header 
    map $scheme $proxy_x_forwarded_ssl { 
    default off; 
    https on; 
    } 


    server { 
     listen 80 default_server; 
     location/{ 
      access_log /var/log/nginx/cache_root.log; 
      proxy_pass http://nmregistry:4873; 
     } 

     location ~* .+/-/.+$ { 
      root     /var/tmp/nginx/npm; 
      expires     max; 
      try_files    $uri @fetch;    
     } 

     location @fetch { 
       internal; 
       proxy_pass    http://nmregistry:4873$request_uri; 

       proxy_store    on; 
       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_store_access  user:rw group:rw all:rw; 
       proxy_temp_path  /var/tmp/nginx/npm 1 2; 
       root     /var/tmp/nginx/npm; 
     } 
    } 
}