Navigation
Artikel
Stuff
RSS Feeds
|
Tutorials - NginxSprachenübersicht/Betriebssysteme/Linux/Internet & Netzwerk Keywords: nginx redirecting small fast quick reverse proxy howto InhaltsverzeichnisVorwort Top
Funktion Top
Installation Top
Code: cd /usr/src/local wget http://sysoev.ru/nginx/nginx-0.5.31.tar.gz tar xvfz nginx-0.5.31.tar.gz cd nginx-0.5.31 ./configure \ --with-poll_module \ --prefix=/usr \ --user=www-data \ --group=www-data \ --conf-path=/etc/nginx/nginx.conf \ --pid-path=/var/run/nginx.pid \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --http-client-body-temp-path=/var/cache/nginx/client-body \ --http-proxy-temp-path=/var/cache/nginx/proxy \ --http-fastcgi-temp-path=/var/cache/nginx/fastcgi \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_dav_module \ --with-http_stub_status_module \ --with-http_flv_module make && make install
Konfiguration Top
/etc/nginx/nginx.conf: user www-data; worker_processes 2; error_log /var/log/nginx/error.log warn; events { worker_connections 8192; use epoll; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - - [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" ' '"$gzip_ratio"'; log_format full '$remote_addr - - [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent" "$http_host" ' '$request_time "$http_x_forwarded_for" "$http_via" ' '"$gzip_ratio"'; log_format timing '$remote_addr - $remote_user [$time_local] ' '$request upstream_response_time $upstream_response_time ' 'msec $msec request_time $request_time'; access_log /var/log/nginx/access.log combined; proxy_connect_timeout 120; server_names_hash_bucket_size 64; client_header_timeout 10m; client_body_timeout 10m; send_timeout 10m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 4 2k; request_pool_size 4k; client_max_body_size 10m; gzip on; gzip_min_length 1100; gzip_buffers 4 8k; gzip_types text/css text/plain text/html application/x-javascript; output_buffers 1 32k; postpone_output 1460; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 75 20; ignore_invalid_headers on; index index.html; upstream varnish { server 127.0.0.1:6081; } include /etc/nginx/vhosts.d/*.conf; }
/etc/nginx/vhosts.d/example.com: server { listen 80; server_name www.example.com; rewrite ^(.*)$ http://example.com$1 permanent; } server { listen 80; server_name example.com; access_log /var/log/nginx/example.com_access.log combined; location ^~ /static/ { root /var/www/example.com; } location ^~ /foobar/ { rewrite ^/foobar/(.*)$ /something-else/$1; root /var/www/example.com; } error_page 403 /static/error/403.html; error_page 404 /static/error/404.html; error_page 500 /static/error/500.html; error_page 502 /static/error/502.html; error_page 503 /static/error/503.html; error_page 504 /static/error/504.html; # everything else goes here location ^~ '/' { # offline page #return 503; proxy_read_timeout 300; proxy_set_header Host $host; proxy_pass http://varnish; } }
Schlusswort Top
Siehe auch Top
Weblinks Top
Gibt es noch irgendwelche Fragen, oder wollen Sie über den Artikel diskutieren? Sprachenübersicht/Betriebssysteme/Linux/Internet & Netzwerk/Nginx |