NginX
Debugging Variables
NginX has many predefined, global variables.
To see all vars create file /etc/nginx/includes/return_vars.conf
##### To test NginX variables on domain use port 85 -- www.somedomain.loc:85 ######
server {
listen 85;
server_name $host;
add_header Content-Type text/plain;
return 200 "
## BASIC NGINX VARS (<a href='http://www.localhost.loc:85/html/index.php?id=5'>http://www.localhost.loc:85/html/index.php?id=5</a>)## <br><br>
scheme= $scheme <br>
host= $host <br>
server_port= $server_port <br>
uri= $uri <br>
args= $args <br>
<br>
request_uri= $request_uri <br>
<br>
status= $status <br>
<br><br><br><br> ## MOST NGINX VARS ## <br><br>
ancient_browser= $ancient_browser <br>
arg_= $arg_ <br>
args= $args <br>
binary_remote_addr= $binary_remote_addr <br>
body_bytes_sent= $body_bytes_sent <br>
bytes_sent= $bytes_sent (ngx_http_core_module) <br>
bytes_sent= $bytes_sent (ngx_http_log_module) <br>
connection= $connection (ngx_http_core_module) <br>
connection_requests= $connection_requests (ngx_http_core_module) <br>
content_length= $content_length <br>
content_type= $content_type <br>
cookie_= $cookie_ <br>
date_gmt= $date_gmt <br>
date_local= $date_local <br>
document_root= $document_root <br>
document_uri= $document_uri <br>
fastcgi_path_info= $fastcgi_path_info <br>
fastcgi_script_name= $fastcgi_script_name <br>
gzip_ratio= $gzip_ratio <br>
host= $host <br>
hostname= $hostname <br>
http_= $http_ <br>
https= $https <br>
modern_browser= $modern_browser <br>
msec=$msec <br>
msie=$msie <br>
nginx_version=$nginx_version <br>
pid=$pid <br>
pipe=$pipe <br>
proxy_add_x_forwarded_for= $proxy_add_x_forwarded_for <br>
proxy_host= $proxy_host <br>
proxy_port= $proxy_port <br>
proxy_protocol_addr= $proxy_protocol_addr <br>
query_string= $query_string <br>
realpath_root= $realpath_root <br>
remote_addr= $remote_addr <br>
remote_port= $remote_port <br>
remote_user= $remote_user <br>
request= $request <br>
request_body= $request_body <br>
request_body_file= $request_body_file <br>
request_completion= $request_completion <br>
request_filename= $request_filename <br>
request_length= $request_length (ngx_http_core_module, ngx_http_log_module) <br>
request_method= $request_method <br>
request_time= $request_time (ngx_http_core_module, ngx_http_log_module) <br>
request_uri= $request_uri <br>
scheme= $scheme <br>
secure_link= secure_link <br>
secure_link_expires= secure_link_expires <br>
sent_http_= $sent_http_ <br>
server_addr= $server_addr <br>
server_name= $server_name <br>
server_port= $server_port <br>
server_protocol= $server_protocol <br>
<br>
ssl_cipher= $ssl_cipher <br>
ssl_client_cert= $ssl_client_cert <br>
ssl_client_i_dn= $ssl_client_i_dn <br>
ssl_client_raw_cert= $ssl_client_raw_cert <br>
ssl_client_s_dn= $ssl_client_s_dn <br>
ssl_client_serial= $ssl_client_serial <br>
ssl_client_verify= $ssl_client_verify <br>
ssl_protocol= $ssl_protocol <br>
ssl_server_name= ssl_server_name <br>
ssl_session_id= $ssl_session_id <br>
ssl_session_reused= $ssl_session_reused <br>
<br>
status= $status (ngx_http_core_module, ngx_http_log_module) <br>
time_iso8601= $time_iso8601 (ngx_http_core_module, ngx_http_log_module) <br>
time_local= $time_local (ngx_http_core_module, ngx_http_log_module) <br>
uid_got= $uid_got <br>
uid_reset= $uid_reset <br>
uid_set= $uid_set <br>
upstream_addr= $upstream_addr <br>
upstream_cache_status= $upstream_cache_status <br>
upstream_http_...= $upstream_http_... <br>
upstream_response_length= $upstream_response_length <br>
upstream_response_time= $upstream_response_time <br>
upstream_status= $upstream_status <br>
= <br>
= <br>
= <br>
= <br>
";
}
Now include it at the end of virtual host file /etc/nginx/sites-available/loc_adsuu_www.conf
#redirect to www
server {
server_name adsuu.loc;
return 301 $scheme://www.$host$request_uri;
}
server {
############### General Settings ####################
listen 80;
server_name www.adsuu.loc;
root "/homemiko/com_adsuu/www/public_html/";
index index.php index.html;
charset utf-8;
autoindex on;
error_log "/homemiko/com_adsuu/logs/www_adsuu_com_error.log";
#access_log "/homemiko/com_adsuu/logs/www_adsuu_com_access.log";
################# Includes ###################
include /etc/nginx/includes/htaccess.conf;
include /etc/nginx/includes/php.conf;
}
########## Debugging ############
include /etc/nginx/includes/return_vars.conf;
Now you can test NginX variables for the specific domain.
For example if you have URL http://www.somedomain.com/dir1/dir2/test.php?u=john&pass=drek you can test NginX vars with adding port 85
http://www.somedomain.com:85/dir1/dir2/test.php?u=john&pass=drek
The listing will be:
## BASIC NGINX VARS (<a href='http://www.localhost.loc:85/html/index.php?id=5'>http://www.localhost.loc:85/html/index.php?id=5</a>)## <br><br> scheme= http <br> host= www.adsuu.loc <br> server_port= 85 <br> uri= / <br> args= <br> <br> request_uri= / <br> <br> status= 200 <br> <br><br><br><br> ## MOST NGINX VARS ## <br><br> ancient_browser= 1 <br> arg_= <br> args= <br> binary_remote_addr= �� <br> body_bytes_sent= 0 <br> bytes_sent= 0 (ngx_http_core_module) <br> bytes_sent= 0 (ngx_http_log_module) <br> connection= 5 (ngx_http_core_module) <br> connection_requests= 1 (ngx_http_core_module) <br> content_length= <br> content_type= <br> cookie_= <br> date_gmt= Thursday, 19-Feb-2015 00:35:58 GMT <br> date_local= Thursday, 19-Feb-2015 01:35:58 CET <br> document_root= /usr/share/nginx/html <br> document_uri= / <br> fastcgi_path_info= <br> fastcgi_script_name= / <br> gzip_ratio= <br> host= www.adsuu.loc <br> hostname= komp <br> http_= <br> https= <br> modern_browser= <br> msec=1424306158.768 <br> msie= <br> nginx_version=1.6.2 <br> pid=2392 <br> pipe=. <br> proxy_add_x_forwarded_for= 127.0.0.1 <br> proxy_host= <br> proxy_port= <br> proxy_protocol_addr= <br> query_string= <br> realpath_root= /usr/share/nginx/html <br> remote_addr= 127.0.0.1 <br> remote_port= 40229 <br> remote_user= <br> request= GET / HTTP/1.1 <br> request_body= <br> request_body_file= <br> request_completion= <br> request_filename= /usr/share/nginx/html/ <br> request_length= 332 (ngx_http_core_module, ngx_http_log_module) <br> request_method= GET <br> request_time= 0.000 (ngx_http_core_module, ngx_http_log_module) <br> request_uri= / <br> scheme= http <br> secure_link= secure_link <br> secure_link_expires= secure_link_expires <br> sent_http_= <br> server_addr= 127.0.0.1 <br> server_name= $host <br> server_port= 85 <br> server_protocol= HTTP/1.1 <br> <br> ssl_cipher= <br> ssl_client_cert= <br> ssl_client_i_dn= <br> ssl_client_raw_cert= <br> ssl_client_s_dn= <br> ssl_client_serial= <br> ssl_client_verify= <br> ssl_protocol= <br> ssl_server_name= ssl_server_name <br> ssl_session_id= <br> ssl_session_reused= <br> <br> status= 200 (ngx_http_core_module, ngx_http_log_module) <br> time_iso8601= 2015-02-19T01:35:58+01:00 (ngx_http_core_module, ngx_http_log_module) <br> time_local= 19/Feb/2015:01:35:58 +0100 (ngx_http_core_module, ngx_http_log_module) <br> uid_got= <br> uid_reset= <br> uid_set= <br> upstream_addr= <br> upstream_cache_status= <br> upstream_http_...= ... <br> upstream_response_length= <br> upstream_response_time= <br> upstream_status= <br> = <br> = <br> = <br> = <br>