Linux installation and configuration tutorial, linuxnginx tutorial

Source: Internet
Author: User

Linux installation and configuration tutorial, linuxnginx tutorial
Installation and configuration of nginx in Linux

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_ B Ytes_sent "$ http_referer" ''" $ http_user_agent "" $ response "$ upstream_addr [$ request_time, $ Response]" $ 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 configuration details
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 x.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 ;}
Configure 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 10 m; # maximum number of single file bytes allowed for client requests client_body_buffer_size 128 k; # maximum number of bytes for buffer client requests by the buffer proxy, proxy_connect_timeout 90; # nginx and backend server connection timeout (proxy connection timeout) proxy_send_timeout 90; # backend server data return time (proxy sending timeout) proxy_read_timeout 90; # after successful connection, response time of the backend server (proxy receiving timeout) proxy_buffer_size 4 k; # Set the buffer size proxy_buffers 4 32 k for the proxy server (nginx) to save user header information; # proxy_buffers buffer, set proxy_busy_buffers_size 64 k; # proxy_temp_file_write_size 64 k under high load (proxy_buffers * 2) proxy_temp_file_write_size 64 k; # Set the cache folder size, greater than this value, upload data from the upstream Server
Start nginx
Cd/usr/local/nginx/sbin/./nginx-t (test whether the configuration is correct)./nginx-s reload

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.