nginx 역방향 에이전트 apache 2, pp - fpm, uwsgi 설정

3413 단어 nginxfastcgiuwsgi
1. nginx 역방향 에이전트 설정 사례
#user  nobody;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;
worker_rlimit_nofile 65535;

events {
    use epoll;
    worker_connections  4096;
}


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  180;
    client_max_body_size 500m;
    #gzip  on;
    #     Apache2
    server
	{
		listen 80;
		server_name eblog.com;
		location / {
			proxy_set_header Host $host;
			proxy_set_header X-Real-IP $remote_addr;
			proxy_set_header REMOTE-HOST $remote_addr;
			proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			proxy_pass http://127.0.0.1:8888;
		}
	}
	#    ,Apache2  mod_php    php  
	server
	{
			listen 80;
			server_name shop.com test.com;
			location / {
					proxy_set_header Host $host;
					proxy_set_header X-Real-IP $remote_addr;
					proxy_set_header REMOTE-HOST $remote_addr;
					proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
					proxy_pass http://127.0.0.1:8888;
			}
	}
	#    ,   php-fpm      php  
    server{
		listen	80;
		server_name api.com;
		index index.php;
		root /var/www/yaf_api/public;
		if (!-e $request_filename) {
			rewrite ^/(.*)  /index.php?$1 last;
		}

		location ~ .php$ {
			fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
			fastcgi_index index.php;
			fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
			include fastcgi_params;
		}
		access_log /var/log/yaf_api/yaf.api.log;
	}
	
	#     python
	server 
	{
			listen       80;
			server_name  webchat.com;
			
			location / {           
			root /var/www/webchat;
				include  uwsgi_params;
				uwsgi_pass  127.0.0.1:9090;              #   uwsgi      
				uwsgi_param UWSGI_SCRIPT webchat.wsgi;  #    , wsgi.py           ,“.”       
				uwsgi_param UWSGI_CHDIR /var/www/webchat;       #     
				index  index.html index.htm;
				client_max_body_size 35m;
			}
	}

    # HTTPS server
    #
	server {
		listen       443 ssl;
		server_name  test.com;
		access_log logs/https-access.log;
		error_log logs/https-error.log;
		ssl on;
		#HTTPS   
		ssl_certificate      /home/web/myssl/server-cert.pem;
		ssl_certificate_key  /home/web/myssl/server-key.pem;
		#HTTPS    ,       
		ssl_client_certificate /home/web/myssl/ca-cert.pem;
		ssl_verify_client on;

		ssl_session_cache    shared:SSL:1m;
		ssl_session_timeout  5m;

		ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
		ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
		ssl_prefer_server_ciphers on;
		   
		error_page   500 502 503 504  /50x.html;
		location = /50x.html {
			 root   html;
		}
		location / {
			 proxy_set_header Host $host;
			 proxy_set_header X-Real-IP $remote_addr;
			 proxy_set_header REMOTE-HOST $remote_addr;
			 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
			 proxy_pass http://127.0.0.1:8888
		}
	}

}

주: uwsgi 설정 은 nginx + uwsgi 배치 python django 웹 서 비 스 를 참고 할 수 있 습 니 다.

좋은 웹페이지 즐겨찾기