Quantcast
Channel: Библиотека знаний
Viewing all articles
Browse latest Browse all 1318

Nginx - Вопросы и Ответы

$
0
0

Nginx - Вопросы и Ответы

Вопросы-Ответы

Q: Нада перенаправить с site.com на www.site.com

server{listen80;server_name site.com;return301http://www.site.com$request_uri;} 
server{listen80;server_name  www.site.com;}

Q: Надо перенаправить на другую папку

  • location /d { rewrite ^ other-folder permanent; }

Q: Надо перенаправить GET на другой сервер

  • location /d { 
      rewrite ^ http://server.ru$request_uri? permanent; #301 redirect 
    }

Q: Надо перенаправить GET|POST на другой сервер

*Q: Надо переправить в другой location, используя ошибку

Q: Блокировка IP адресов и подсететей в Nginx

  • Q: Настройка proxy_pass на удаленный домен по DNS
  • location ^~ /freegeoip/ {#use google as dnsresolver 8.8.8.8;proxy_passhttp://freegeoip.net/json/$remote_addr;}

Q: Как запаролить location в Nginx

  • location ^~ /secure/ {root /www/mysite.com/httpdocs/secure;auth_basic"Website development";auth_basic_user_file  /www/mysite.com/authfile;}

    Затем генерируем сам файл, где логин будет admin, а пароль pass

    php -r "echo 'admin:'. crypt('pass', base64_encode('pass'));" > /www/mysite.com/authfile

Q: Как перенаправить обработку скрипта в другую папку

server{listen80;server_name site.com;location ^~ /api/target/ { 
	index receive.php; 
	alias /some/path/to/site/target/; 
        location~ \.php$ { 
        	# Fix for server variables that behave differently under nginx/php-fpm than typically expectedfastcgi_split_path_info ^(.+\.php)(/.+)$; 
		# Include the standard fastcgi_params file included with nginxinclude fastcgi_params; 
        	fastcgi_param  PATH_INFO        $fastcgi_path_info;fastcgi_index receive.php; 
        	# Override the SCRIPT_FILENAME variable set by fastcgi_paramsfastcgi_param  SCRIPT_FILENAME  $request_filename; 
        	# Pass to upstream PHP-FPM; This must match whatever you name your upstream connectionfastcgi_pass phpfpm; 
		#fastcgi_ignore_client_abort off;#try_files $uri =404; 
        } 
    }}

Q: Количество открытых файлов и их лимиты

for pid in`pidof nginx`; doecho"$(< /proc/$pid/cmdline)"; egrep'files|Limit'/proc/$pid/limits; echo"Currently open files: $(ls -1 /proc/$pid/fd | wc -l)"; echo; done

Viewing all articles
Browse latest Browse all 1318

Trending Articles


Girasoles para colorear


mayabang Quotes, Torpe Quotes, tanga Quotes


Tagalog Quotes About Crush – Tagalog Love Quotes


OFW quotes : Pinoy Tagalog Quotes


Long Distance Relationship Tagalog Love Quotes


Tagalog Quotes To Move on and More Love Love Love Quotes


5 Tagalog Relationship Rules


Best Crush Tagalog Quotes And Sayings 2017


Re:Mutton Pies (lleechef)


FORECLOSURE OF REAL ESTATE MORTGAGE


Sapos para colorear


tagalog love Quotes – Tiwala Quotes


Break up Quotes Tagalog Love Quote – Broken Hearted Quotes Tagalog


Patama Quotes : Tagalog Inspirational Quotes


Pamatay na Banat and Mga Patama Love Quotes


Tagalog Long Distance Relationship Love Quotes


BARKADA TAGALOG QUOTES


“BAHAY KUBO HUGOT”


Vimeo 10.7.0 by Vimeo.com, Inc.


Vimeo 10.7.1 by Vimeo.com, Inc.