Nginx

Nginx (2)

Reverse Proxy & Log Format

  • Published in Nginx

  • ( ! ) Notice: Undefined property: Joomla\CMS\User\User::$profile in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php on line 49
    Call Stack
    #TimeMemoryFunctionLocation
    10.0003397752{main}( ).../index.php:0
    20.03051348144Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
    30.03051348144Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
    40.12542778112Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
    50.12562799936Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
    60.12612855288Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
    70.12612872344require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
    80.12983004584K2ControllerItemlist->execute( $task = 'category' ).../k2.php:64
    90.12983004584K2ControllerItemlist->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
    100.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../itemlist.php:49
    110.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
    120.13273035696Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItemlist { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'Nginx'; public $description = ''; public $link = ''; public $base = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'itemlist'; protected $_models = ['item' => class K2ModelItem { ... }, 'itemlist' => class K2ModelItemlist { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'itemlist'; protected $_layout = 'category'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $now = '2021-11-30 21:06:40'; public $nullDate = '0000-00-00 00:00:00'; public $category = class TableK2Category { public $id = '93'; public $name = 'Nginx'; public $alias = 'nginx'; public $description = ''; public $parent = '0'; public $extraFieldsGroup = '0'; public $published = '1'; public $image = '/components/com_k2/images/placeholder/category.png'; public $access = '1'; public $ordering = '18'; public $params = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $trash = '0'; public $plugins = ''; public $language = '*'; protected $_tbl = '#__k2_categories'; protected $_tbl_key = 'id'; protected $_tbl_keys = [...]; protected $_db = class JDatabaseDriverMysqli { ... }; protected $_trackAssets = FALSE; protected $_rules = NULL; protected $_locked = FALSE; protected $_autoincrement = TRUE; protected $_observers = class JObserverUpdater { ... }; protected $_columnAlias = [...]; protected $_jsonEncode = [...]; protected $_errors = [...]; public $metaDescription = NULL; public $metaKeywords = NULL; public $metaRobots = NULL; public $metaAuthor = NULL; public $link = '/component/k2/itemlist/category/93-nginx.html'; public $text = ''; public $jcfields = [...]; public $event = class stdClass { ... } }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $feed = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html&format=feed'; public $leading = [0 => class stdClass { ... }, 1 => class stdClass { ... }]; public $primary = []; public $secondary = []; public $links = []; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 14; public $total = 2; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 1; public $pagesCurrent = 1; public $pagesTotal = 1; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL }; public $item = class stdClass { public $id = '557'; public $title = 'Reverse Proxy &amp; Log Format'; public $alias = 'reverse-proxy-log-format'; public $catid = '93'; public $published = '1'; public $introtext = '<p><span style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;">Tip when you install ispconfig 3 behind a reverse proxy like nginx.</span><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;" /><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = '[]'; public $extra_fields_search = ''; public $created = '2013-10-12 21:16:01'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '63'; public $checked_out_time = '2013-10-12 21:16:51'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-10-12 21:16:01'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '2'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '1528'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $categoryname = 'Nginx'; public $categoryid = '93'; public $categoryalias = 'nginx'; public $categoryparams = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $itemGroup = 'leading'; public $category = class TableK2Category { ... }; public $link = '/item/557-reverse-proxy-log-format.html'; public $printLink = '/item/557-reverse-proxy-log-format.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $rawTitle = 'Reverse Proxy & Log Format'; public $author = class Joomla\CMS\User\User { ... }; public $text = '<p><span style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;">Tip when you install ispconfig 3 behind a reverse proxy like nginx.</span><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;" /><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600' } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
    130.13333056384K2ViewItemlist->display( $tpl = ??? ).../ViewController.php:102
    140.17235893152K2ViewItemlist->display( $tpl = NULL ).../view.html.php:1407
    150.17245893152K2ViewItemlist->loadTemplate( $tpl = NULL ).../HtmlView.php:230
    160.17305969976include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php ).../HtmlView.php:701
    170.17305969976K2ViewItemlist->loadTemplate( $tpl = 'item' ).../category.php:94
    180.17376065600include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php ).../HtmlView.php:701

    ( ! ) Notice: Trying to get property 'gender' of non-object in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php on line 49
    Call Stack
    #TimeMemoryFunctionLocation
    10.0003397752{main}( ).../index.php:0
    20.03051348144Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
    30.03051348144Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
    40.12542778112Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
    50.12562799936Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
    60.12612855288Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
    70.12612872344require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
    80.12983004584K2ControllerItemlist->execute( $task = 'category' ).../k2.php:64
    90.12983004584K2ControllerItemlist->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
    100.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../itemlist.php:49
    110.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
    120.13273035696Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItemlist { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'Nginx'; public $description = ''; public $link = ''; public $base = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'itemlist'; protected $_models = ['item' => class K2ModelItem { ... }, 'itemlist' => class K2ModelItemlist { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'itemlist'; protected $_layout = 'category'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $now = '2021-11-30 21:06:40'; public $nullDate = '0000-00-00 00:00:00'; public $category = class TableK2Category { public $id = '93'; public $name = 'Nginx'; public $alias = 'nginx'; public $description = ''; public $parent = '0'; public $extraFieldsGroup = '0'; public $published = '1'; public $image = '/components/com_k2/images/placeholder/category.png'; public $access = '1'; public $ordering = '18'; public $params = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $trash = '0'; public $plugins = ''; public $language = '*'; protected $_tbl = '#__k2_categories'; protected $_tbl_key = 'id'; protected $_tbl_keys = [...]; protected $_db = class JDatabaseDriverMysqli { ... }; protected $_trackAssets = FALSE; protected $_rules = NULL; protected $_locked = FALSE; protected $_autoincrement = TRUE; protected $_observers = class JObserverUpdater { ... }; protected $_columnAlias = [...]; protected $_jsonEncode = [...]; protected $_errors = [...]; public $metaDescription = NULL; public $metaKeywords = NULL; public $metaRobots = NULL; public $metaAuthor = NULL; public $link = '/component/k2/itemlist/category/93-nginx.html'; public $text = ''; public $jcfields = [...]; public $event = class stdClass { ... } }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $feed = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html&format=feed'; public $leading = [0 => class stdClass { ... }, 1 => class stdClass { ... }]; public $primary = []; public $secondary = []; public $links = []; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 14; public $total = 2; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 1; public $pagesCurrent = 1; public $pagesTotal = 1; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL }; public $item = class stdClass { public $id = '557'; public $title = 'Reverse Proxy &amp; Log Format'; public $alias = 'reverse-proxy-log-format'; public $catid = '93'; public $published = '1'; public $introtext = '<p><span style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;">Tip when you install ispconfig 3 behind a reverse proxy like nginx.</span><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;" /><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = '[]'; public $extra_fields_search = ''; public $created = '2013-10-12 21:16:01'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '63'; public $checked_out_time = '2013-10-12 21:16:51'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-10-12 21:16:01'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '2'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '1528'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $categoryname = 'Nginx'; public $categoryid = '93'; public $categoryalias = 'nginx'; public $categoryparams = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $itemGroup = 'leading'; public $category = class TableK2Category { ... }; public $link = '/item/557-reverse-proxy-log-format.html'; public $printLink = '/item/557-reverse-proxy-log-format.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $rawTitle = 'Reverse Proxy & Log Format'; public $author = class Joomla\CMS\User\User { ... }; public $text = '<p><span style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;">Tip when you install ispconfig 3 behind a reverse proxy like nginx.</span><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-size: 13px; line-height: normal; background-color: #f5f5ff;" /><br style="font-family: verdana, geneva, lucida, \'lucida grande\', arial, helvetica, sans-serif; font-'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600' } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
    130.13333056384K2ViewItemlist->display( $tpl = ??? ).../ViewController.php:102
    140.17235893152K2ViewItemlist->display( $tpl = NULL ).../view.html.php:1407
    150.17245893152K2ViewItemlist->loadTemplate( $tpl = NULL ).../HtmlView.php:230
    160.17305969976include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php ).../HtmlView.php:701
    170.17305969976K2ViewItemlist->loadTemplate( $tpl = 'item' ).../category.php:94
    180.17376065600include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php ).../HtmlView.php:701
    Written by alamise

Tip when you install ispconfig 3 behind a reverse proxy like nginx.

In /etc/apache2/sites-available/ispconfig.conf changes '%h' to '%{X-Real-IP}i' to get this:

Code:
LogFormat "%v %{X-Real-IP}i %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined_ispconfig

In order to apache logs for awstats works properly.

I've also defined in my /etc/nginx/nginx.conf config file:

Code:
proxy_set_header   X-Real-IP        $remote_addr;

A better solution will be appreciated

Read more...

nginx反向代理

  • Published in Nginx

  • ( ! ) Notice: Undefined property: Joomla\CMS\User\User::$profile in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php on line 49
    Call Stack
    #TimeMemoryFunctionLocation
    10.0003397752{main}( ).../index.php:0
    20.03051348144Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
    30.03051348144Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
    40.12542778112Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
    50.12562799936Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
    60.12612855288Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
    70.12612872344require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
    80.12983004584K2ControllerItemlist->execute( $task = 'category' ).../k2.php:64
    90.12983004584K2ControllerItemlist->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
    100.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../itemlist.php:49
    110.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
    120.13273035696Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItemlist { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'Nginx'; public $description = ''; public $link = ''; public $base = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'itemlist'; protected $_models = ['item' => class K2ModelItem { ... }, 'itemlist' => class K2ModelItemlist { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'itemlist'; protected $_layout = 'category'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $now = '2021-11-30 21:06:40'; public $nullDate = '0000-00-00 00:00:00'; public $category = class TableK2Category { public $id = '93'; public $name = 'Nginx'; public $alias = 'nginx'; public $description = ''; public $parent = '0'; public $extraFieldsGroup = '0'; public $published = '1'; public $image = '/components/com_k2/images/placeholder/category.png'; public $access = '1'; public $ordering = '18'; public $params = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $trash = '0'; public $plugins = ''; public $language = '*'; protected $_tbl = '#__k2_categories'; protected $_tbl_key = 'id'; protected $_tbl_keys = [...]; protected $_db = class JDatabaseDriverMysqli { ... }; protected $_trackAssets = FALSE; protected $_rules = NULL; protected $_locked = FALSE; protected $_autoincrement = TRUE; protected $_observers = class JObserverUpdater { ... }; protected $_columnAlias = [...]; protected $_jsonEncode = [...]; protected $_errors = [...]; public $metaDescription = NULL; public $metaKeywords = NULL; public $metaRobots = NULL; public $metaAuthor = NULL; public $link = '/component/k2/itemlist/category/93-nginx.html'; public $text = ''; public $jcfields = [...]; public $event = class stdClass { ... } }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $feed = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html&format=feed'; public $leading = [0 => class stdClass { ... }, 1 => class stdClass { ... }]; public $primary = []; public $secondary = []; public $links = []; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 14; public $total = 2; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 1; public $pagesCurrent = 1; public $pagesTotal = 1; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL }; public $item = class stdClass { public $id = '551'; public $title = 'nginx反向代理'; public $alias = 'nginx反向代理'; public $catid = '93'; public $published = '1'; public $introtext = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = '[]'; public $extra_fields_search = ''; public $created = '2013-09-27 15:04:14'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '0'; public $checked_out_time = '0000-00-00 00:00:00'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-09-27 15:04:14'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '1'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '2990'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $categoryname = 'Nginx'; public $categoryid = '93'; public $categoryalias = 'nginx'; public $categoryparams = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $itemGroup = 'leading'; public $category = class TableK2Category { ... }; public $link = '/item/551-nginx反向代理.html'; public $printLink = '/item/551-nginx反向代理.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $rawTitle = 'nginx反向代理'; public $author = class Joomla\CMS\User\User { ... }; public $text = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600' } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
    130.13333056384K2ViewItemlist->display( $tpl = ??? ).../ViewController.php:102
    140.17235893152K2ViewItemlist->display( $tpl = NULL ).../view.html.php:1407
    150.17245893152K2ViewItemlist->loadTemplate( $tpl = NULL ).../HtmlView.php:230
    160.17305969976include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php ).../HtmlView.php:701
    170.17526069896K2ViewItemlist->loadTemplate( $tpl = 'item' ).../category.php:94
    180.17576120112include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php ).../HtmlView.php:701

    ( ! ) Notice: Trying to get property 'gender' of non-object in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php on line 49
    Call Stack
    #TimeMemoryFunctionLocation
    10.0003397752{main}( ).../index.php:0
    20.03051348144Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
    30.03051348144Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
    40.12542778112Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
    50.12562799936Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
    60.12612855288Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
    70.12612872344require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
    80.12983004584K2ControllerItemlist->execute( $task = 'category' ).../k2.php:64
    90.12983004584K2ControllerItemlist->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
    100.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../itemlist.php:49
    110.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
    120.13273035696Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItemlist { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'Nginx'; public $description = ''; public $link = ''; public $base = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'itemlist'; protected $_models = ['item' => class K2ModelItem { ... }, 'itemlist' => class K2ModelItemlist { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'itemlist'; protected $_layout = 'category'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $now = '2021-11-30 21:06:40'; public $nullDate = '0000-00-00 00:00:00'; public $category = class TableK2Category { public $id = '93'; public $name = 'Nginx'; public $alias = 'nginx'; public $description = ''; public $parent = '0'; public $extraFieldsGroup = '0'; public $published = '1'; public $image = '/components/com_k2/images/placeholder/category.png'; public $access = '1'; public $ordering = '18'; public $params = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $trash = '0'; public $plugins = ''; public $language = '*'; protected $_tbl = '#__k2_categories'; protected $_tbl_key = 'id'; protected $_tbl_keys = [...]; protected $_db = class JDatabaseDriverMysqli { ... }; protected $_trackAssets = FALSE; protected $_rules = NULL; protected $_locked = FALSE; protected $_autoincrement = TRUE; protected $_observers = class JObserverUpdater { ... }; protected $_columnAlias = [...]; protected $_jsonEncode = [...]; protected $_errors = [...]; public $metaDescription = NULL; public $metaKeywords = NULL; public $metaRobots = NULL; public $metaAuthor = NULL; public $link = '/component/k2/itemlist/category/93-nginx.html'; public $text = ''; public $jcfields = [...]; public $event = class stdClass { ... } }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $feed = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html&format=feed'; public $leading = [0 => class stdClass { ... }, 1 => class stdClass { ... }]; public $primary = []; public $secondary = []; public $links = []; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 14; public $total = 2; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 1; public $pagesCurrent = 1; public $pagesTotal = 1; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL }; public $item = class stdClass { public $id = '551'; public $title = 'nginx反向代理'; public $alias = 'nginx反向代理'; public $catid = '93'; public $published = '1'; public $introtext = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = '[]'; public $extra_fields_search = ''; public $created = '2013-09-27 15:04:14'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '0'; public $checked_out_time = '0000-00-00 00:00:00'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-09-27 15:04:14'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '1'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '2990'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $categoryname = 'Nginx'; public $categoryid = '93'; public $categoryalias = 'nginx'; public $categoryparams = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $itemGroup = 'leading'; public $category = class TableK2Category { ... }; public $link = '/item/551-nginx反向代理.html'; public $printLink = '/item/551-nginx反向代理.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $rawTitle = 'nginx反向代理'; public $author = class Joomla\CMS\User\User { ... }; public $text = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600' } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
    130.13333056384K2ViewItemlist->display( $tpl = ??? ).../ViewController.php:102
    140.17235893152K2ViewItemlist->display( $tpl = NULL ).../view.html.php:1407
    150.17245893152K2ViewItemlist->loadTemplate( $tpl = NULL ).../HtmlView.php:230
    160.17305969976include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php ).../HtmlView.php:701
    170.17526069896K2ViewItemlist->loadTemplate( $tpl = 'item' ).../category.php:94
    180.17576120112include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php ).../HtmlView.php:701
    Written by alamise

Nginx代理与负载均衡配置与优化

 Nginx代理

 Nginx0.7.48版本开始,支持了类似Squid的缓存功能。NginxWeb缓存服务主要由proxy_cache相关指令集和fastcgi_cache相关指令集构成,前者用于反向代理时,对后端内容源服务器进行缓存,后者主要用于对FastCGI的动态程序进行缓存。两者的功能基本上一样。

 Nginx 0.8.32版本,proxy_cachefastcgi_cache已经比较完善,加上第三方的ngx_cache_purge模块(用于清除指定URL的缓存),已经可以完全取代Squid

 在功能上,Nginx已经具备Squid所拥有的Web缓存加速功能、清除指定URL缓存的功能。而在性能上,Nginx对多核CPU的利用,胜过Squid不少。另外,在反向代理、负载均衡、健康检查、后端服务器故障转移、Rewrite重写、易用性上,Nginx也比Squid强大得多。这使得一台Nginx可以同时作为负载均衡服务器“Web缓存服务器来使用。

 下面的文档说明了nginx如何做代理服务器,将请求转发到其他服务器,本身不做缓存。使用版本为nginx-0.8.15,配置如下:

 http

{

……..

     client_max_body_size           300m          ;                  // 允许客户端请求的最大单个文件字节数

         client_body_buffer_size       128k;         

         // 缓冲区代理缓冲用户端请求的最大字节数,可以理解为先保存到本地再传给用户

         proxy_connect_timeout          600;

    // 跟后端服务器连接的超时时间_发起握手等候响应超时时间

    // 连接成功后_等候后端服务器响应时间_其实已经进入后端排队之中等候处理

  1. 告诉nginx保存单个用的几个buffer最大用多大空间
 

// proxy缓存临时文件的大小

        server 192.168.0.110:80 weight=5;

        server 192.168.0.121:80 weight=5;

    }

    upstream mysrv {

        server 192.168.0.32:80 weight=2;

        server 127.0.0.1:8000 weight=8;

    }

    server {

        listen       80;

        server_name  club.xywy.com;

        charset gbk;

        root  /www;

        access_log logs/aaa.log combined;

//下面是第一个域名,使用clubsrv的代理

        location / {

            proxy_next_upstream http_502 http_504 error timeout invalid_header;

// 如果后端服务器返回502504或执行超时等错误,自动将请求转发到upstream另一台服务器

            proxy_pass  http://clubsrv;>

// 与上面upstream自己命名的名字填写一致

            proxy_redirect     off;

            proxy_set_header   Host            club.xywy.com;

            proxy_set_header   X-Real-IP        $remote_addr;

            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

// nginx在前端做代理,后端的日志会显示127.0.0.1,上面配置可以显示用户真实IP(还需装第三方软件,见下面的详细说明)

            index  index.htm index.html index.php;

        }

//下面是第二个域名,使用mysrv的代理,访问www.sum.com/message目录下的

    server {

        listen       80;

        server_name  www.sum.com;

        location /message {

           proxy_pass  http://mysrv;>

           proxy_set_header   Host            $host;

// 访问这个域名的,只有mysrv 本机可以访问

          }

//访问除了/message之外的www.sum.com/ 地址,

        location / {

           proxy_pass  http://mysrv;>

           proxy_set_header   Host            $host;

                     proxy_set_header   X-Real-IP       $remote_addr;

下面的配置,与上面错误返回的效果相同,这里可以不写。

 

error_page   500 502 503 504  /50x.html;  

location = /50x.html

{

   root   html;

}

 

2Nginx负载均衡指令 

Nginx属于软件的七层负载均衡(lvs是软件的四层负载均衡的代表),七层负载均衡软件还有L7SWLayer7 switching)、HAProxy等。支持负载均衡的模块是Http Upstream。下面介绍此模块及他下面的几个指令 

HTTP Upstream模块

 1ip_hash指令 

当对后端的多台动态应用服务器做负载均衡时,ip_hash指令将某个客户端IP的请求通过哈希算法定位到同一台后端服务器上。这样,当来自某ip用户在Sever A上登录后,再访问该站点的其他URL时,能保证访问仍在Server A上。如果不加ip_hash,加入用户在Server A上登录,再访问该站点其他URL,就有可能跳转到后端的Sever BC…..,而session记录在A上,BC上没有,就会提示用户未登录。

注意:但这种访问不能保证后端服务器的负载均衡,可能后端有些server接受到的请求多,有些server接受的少,设置的权重值不起作用。

建议如果后端的动态应用程序服务器能做到session共享,而不用nginx上配置ip_hash的方式。

 

upstream mysrv {

        ip_hash;

        server 192.168.0.110:80 weight=2;

        server 127.0.0.1:8000 down;

        server 192.168.0.212:80 weight=8;

    }

2server指令

该指令用语指定后端服务器的名称和参数。服务器的名称可以是一个域名,一个ip,端口号或UNIX Socket

参数介绍:

weight=number 设置服务器权重,权重值越高,被分配到客户端请求数越多。默认为1

max_fails=numbser fail_timeout指定的时间内对后端服务器请求失败的次数,如果检测到后端服务器无法连接及发生错误(404除外),则标记为失败。如果没有设置,默认为1。设置为0则关闭这项检查。

fail_timeout=time 在经历参数max_fails设置的失败次数后,暂停的时间。

配置如下:

upstream mysrv {

        ip_hash;

        server  www.xywy.com  weight=2;

        server  127.0.0.1:8000   down;

        server  192.168.0.212:80  max_fails=3  fail_timeout=30s;

        server  unix:/tmp/bakend3;

    }

Read more...
Subscribe to this RSS feed
( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php on line 191
Call Stack
#TimeMemoryFunctionLocation
10.0003397752{main}( ).../index.php:0
20.03051348144Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.03051348144Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.12542778112Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
50.12562799936Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
60.12612855288Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
70.12612872344require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
80.12983004584K2ControllerItemlist->execute( $task = 'category' ).../k2.php:64
90.12983004584K2ControllerItemlist->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
100.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../itemlist.php:49
110.13213028184K2ControllerItemlist->display( $cachable = TRUE, $urlparams = ['limit' => 'UINT', 'limitstart' => 'UINT', 'id' => 'INT', 'tag' => 'STRING', 'searchword' => 'STRING', 'day' => 'INT', 'year' => 'INT', 'month' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'ordering' => 'CMD', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
120.13273035696Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItemlist { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'Nginx'; public $description = ''; public $link = ''; public $base = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'itemlist'; protected $_models = ['item' => class K2ModelItem { ... }, 'itemlist' => class K2ModelItemlist { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'itemlist'; protected $_layout = 'category'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category_item.php'; protected $_output = '\n<article class="itemView groupLeading"> \t\n\t\t<time datetime="2013-09-27T17:04:14+02:00">\n\t\t27 Sep\t</time>\n\t\t\t\n\t<section>\t\t\n\t\t<header>\n\t\t\t\t\n\t\t\t\t\t\t<h2>\n\t\t\t\t\t\t\t\t\t\t<a href="/item/551-nginx反向代理.html">nginx反向代理</a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</h2>\n\t\t\t\t\t\t\n\t\t\t<ul>\n\t\t\t\t\t\t\t\t<li class="itemCategory"> <span>Published in</span> <a href="/itemlist/category/93-nginx.html">Nginx</a> </li>\n\t\t\t\t\t\t\t\t\t\t\t\t<li class="itemAuthor"> <br />\'; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $now = '2021-11-30 21:06:40'; public $nullDate = '0000-00-00 00:00:00'; public $category = class TableK2Category { public $id = '93'; public $name = 'Nginx'; public $alias = 'nginx'; public $description = ''; public $parent = '0'; public $extraFieldsGroup = '0'; public $published = '1'; public $image = '/components/com_k2/images/placeholder/category.png'; public $access = '1'; public $ordering = '18'; public $params = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $trash = '0'; public $plugins = ''; public $language = '*'; protected $_tbl = '#__k2_categories'; protected $_tbl_key = 'id'; protected $_tbl_keys = [...]; protected $_db = class JDatabaseDriverMysqli { ... }; protected $_trackAssets = FALSE; protected $_rules = NULL; protected $_locked = FALSE; protected $_autoincrement = TRUE; protected $_observers = class JObserverUpdater { ... }; protected $_columnAlias = [...]; protected $_jsonEncode = [...]; protected $_errors = [...]; public $metaDescription = NULL; public $metaKeywords = NULL; public $metaRobots = NULL; public $metaAuthor = NULL; public $link = '/component/k2/itemlist/category/93-nginx.html'; public $text = ''; public $jcfields = [...]; public $event = class stdClass { ... } }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $feed = 'https://www.shan.info/component/k2/itemlist/category/93-nginx.html&format=feed'; public $leading = [0 => class stdClass { ... }, 1 => class stdClass { ... }]; public $primary = []; public $secondary = []; public $links = []; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 14; public $total = 2; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 1; public $pagesCurrent = 1; public $pagesTotal = 1; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL }; public $item = class stdClass { public $id = '551'; public $title = 'nginx反向代理'; public $alias = 'nginx反向代理'; public $catid = '93'; public $published = '1'; public $introtext = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = '[]'; public $extra_fields_search = ''; public $created = '2013-09-27 15:04:14'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '0'; public $checked_out_time = '0000-00-00 00:00:00'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-09-27 15:04:14'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '1'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '2990'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $categoryname = 'Nginx'; public $categoryid = '93'; public $categoryalias = 'nginx'; public $categoryparams = '{"inheritFrom":"0","theme":"","num_leading_items":"2","num_leading_columns":"1","leadingImgSize":"Large","num_primary_items":"4","num_primary_columns":"2","primaryImgSize":"Medium","num_secondary_items":"4","num_secondary_columns":"1","secondaryImgSize":"Small","num_links":"4","num_links_columns":"1","linksImgSize":"XSmall","catCatalogMode":"0","catFeaturedItems":"1","catOrdering":"","catPagination":"2","catPaginationResults":"1","catTitle":"1","catTitleItemCounter":"1","catDescription":"1","catImage":"1","'; public $itemGroup = 'leading'; public $category = class TableK2Category { ... }; public $link = '/item/551-nginx反向代理.html'; public $printLink = '/item/551-nginx反向代理.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $rawTitle = 'nginx反向代理'; public $author = class Joomla\CMS\User\User { ... }; public $text = '<h2 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 31px;"><span style="padding: 0px; margin: 0px; font-family: \'Times New Roman\', serif;">Nginx</span><span style="padding: 0px; margin: 0px; font-family: 宋体;">代理与负载均衡配置与优化</span></h2>\r\n<h3 style="color: #555555; font-family: 宋体, \'Arial Narrow\', arial, serif; line-height: 24px;">&nbsp;<span style="padding: 0px; margin: 0px;">Nginx</span><span style="padding: 0px; margin: 0px; font-'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600' } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
130.13333056384K2ViewItemlist->display( $tpl = ??? ).../ViewController.php:102
140.17235893152K2ViewItemlist->display( $tpl = NULL ).../view.html.php:1407
150.17245893152K2ViewItemlist->loadTemplate( $tpl = NULL ).../HtmlView.php:230
160.17305969976include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php ).../HtmlView.php:701