Linux安裝nginx及配置教程,linuxnginx教程

來源:互聯網
上載者:User

Linux安裝nginx及配置教程,linuxnginx教程
Linux安裝nginx及配置教程

worker_processes  4;error_log   /data/logs/nginx/error.log;#pid        logs/nginx.pid;worker_rlimit_nofile 51200;events {    use epoll;    worker_connections 51200; }http {    include       mime.types;    default_type  application/octet-stream;    include       proxy.conf;    sendfile        on;    tcp_nopush     on;    #keepalive_timeout  0;    keepalive_timeout  65;    log_format  my_access  '$remote_addr - $remote_user [$time_local] "$request" '                '$status $body_bytes_sent "$http_referer" '                '"$http_user_agent" "$http_x_forwarded_for" $upstream_addr [$request_time,$upstream_response_time] "$cookie_serverid"';    access_log  /data/logs/nginx/my.access.log  my_access;    gzip  on;    server {        listen      80;        server_name  127.0.0.1;        set $flag  0;        if ( $request_uri ~* ^/app/(.*) ) {            set $flag  1;        }        if ( $flag = 0 ) {    #       rewrite ^/(.*) https://$server_name/$1 permanent;        }        #rewrite ^/(.*) https://$server_name/$1 permanent;        include my.conf;    }    server {    listen 81;    server_name 127.0.0.1;    location /{        proxy_pass http://127.0.0.1:18080;        proxy_set_header Host $host;        proxy_set_header X-Real-IP $remote_addr;        proxy_set_header X-Forwarded-For          $proxy_add_x_forwarded_for;    }       }#小阿光    upstream my_xagadmin {        server 127.0.0.1:8080;    }    upstream my_xradmin {        server 127.0.0.1:8083;    }}
my.conf配置詳情
server_name 127.0.0.1;#charset koi8-r;if ( $http_cookie ~* "(.*)$"){   set $9fbank_cookie $1;}error_page  404              /404.html;error_page  403              /403.html;location = /404.html {    root   html;}location = /403.html {    root   html;}error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}#小阿光location /xagagent/ {    root  /data/www/;    expires -1;}location /xagdminserver {    proxy_pass                 http://my_xagadmin/xagadminserver;}location /xradmin/ {    proxy_pass                 http://my_xradmin/xradmin/;}location /(WEB-INF)/ {             deny all; }
proxy.conf配置
proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m;    #允許用戶端請求的最大單檔案位元組數client_body_buffer_size 128k;  #緩衝區代理緩衝使用者端請求的最大位元組數,proxy_connect_timeout 90;  #nginx跟後端伺服器連線逾時時間(代理連線逾時)proxy_send_timeout 90;        #後端伺服器資料回傳時間(代理髮送逾時)proxy_read_timeout 90;         #串連成功後,後端伺服器回應時間(代理接收逾時)proxy_buffer_size 4k;   #設定Proxy 伺服器(nginx)儲存使用者頭資訊的緩衝區大小proxy_buffers 4 32k;     #proxy_buffers緩衝區,網頁平均在32k以下的話,這樣設定proxy_busy_buffers_size 64k;    #高負荷下緩衝大小(proxy_buffers*2)proxy_temp_file_write_size 64k;  #設定快取檔案夾大小,大於這個值,將從upstream伺服器傳
nginx 啟動
cd /usr/local/nginx/sbin/./nginx -t(測試組態是否有問題)./nginx -s reload

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.