{"id":271902,"date":"2016-01-11T14:49:02","date_gmt":"2016-01-11T11:49:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=271902"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=271902","title":{"rendered":"\u041a\u0430\u043a \u044f \u043f\u0438\u0441\u0430\u043b web app angular + material \u0438 REST \u043d\u0430 Yii2 + webserver nginx"},"content":{"rendered":"<p>       \u041d\u0430\u0447\u043d\u0443 \u0441 \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041c\u044b\u0441\u043b\u044c \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u2014 \u043c\u043d\u0435 \u044f\u0432\u043d\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412\u043e\u0442 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u0430\u043b, \u0433\u0434\u0435 \u044f \u0441\u043c\u043e\u0433 \u0431\u044b \u0441\u0442\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044e, \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u0440\u0438\u0441\u043a\u0443\u044f \u0440\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u0435\u043d\u044c\u0433\u0430\u043c\u0438.<\/p>\n<p>  \u041d\u0443, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a \u0434\u0435\u043b\u0443. \u0422\u0435\u043c\u0430 \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f, \u043d\u043e \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u043f\u043b\u044b\u043b\u0438 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u042f \u0431\u0443\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 angular. \u0414\u0430, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0441\u0442\u0430\u0442\u0435\u0439.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u042f \u0434\u0430\u0432\u043d\u043e \u0443\u0436\u0435 \u043b\u0435\u043b\u0435\u044f\u043b \u043c\u044b\u0441\u043b\u044c \u0430\u043f\u0440\u043e\u0431\u0438\u0440\u043e\u0432\u0430\u0442\u044c <a href=\"http:\/\/material.angularjs.org\">material.angularjs.org<\/a> \u043d\u0430 \u043a\u0430\u043a\u043e\u043c-\u0442\u043e \u0431\u043e\u0435\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0422\u0443\u0442 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u0438\u0434\u0435\u044f \u0438 \u044f \u0440\u0435\u0448\u0438\u043b\u0441\u044f\u2026 \u0421 \u0432\u0438\u0434\u0443 \u0432\u0441\u0435 \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u2014 \u043d\u0430\u0431\u043e\u0440 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 = \u0431\u044b\u0441\u0442\u0440\u0430\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430, \u043d\u0430 backend \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 Yii \u0438\u2026 \u041d\u043e \u044f \u043d\u0435 \u0440\u0430\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b, \u0447\u0442\u043e \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0432\u043d\u0430\u0447\u0430\u043b\u0435, \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a\u0430\u044f \u0432\u043e\u0437\u043d\u044f \u0441 web-\u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c. \u041a\u0430\u043a \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f, \u0443\u043f\u0441\u2026<\/p>\n<p>  \u041d\u0430\u0447\u0430\u043b\u043e\u0441\u044c \u0432\u0441\u0435 \u0441 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 nginx. \u041f\u043e\u043b\u0443\u0447\u0430\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043a\u0440\u043e\u043c\u0435 \u043d\u0435\u043a\u043e\u0433\u043e REST location, \u043c\u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430 index.html, \u0433\u0434\u0435 \u0443 \u043c\u0435\u043d\u044f \u0438 \u043d\u0430\u0447\u0438\u043d\u0430\u043b \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c angular. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u043b\u0430 \u043f\u0435\u0440\u0432\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"nginx\">server {     charset utf-8;          listen 80;     server_name truemania.ru;      root    \/path\/to\/root;      access_log\t\/path\/to\/root\/log\/access.log;     error_log\t\/path\/to\/root\/log\/error.log;      location \/ {         # Angular app conf          root    \/path\/to\/root\/frontend\/web;          try_files $uri $uri\/ \/index.html =404;     }      location ~* \\.php$ {         include fastcgi_params;         #fastcgi_pass   127.0.0.1:9000;         fastcgi_pass unix:\/var\/run\/php5-fpm.sock;         try_files $uri =404;         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;     }      # avoid processing of calls to non-existing static files by Yii (uncomment if necessary)     location ~* \\.(css|js|jpg|jpeg|png|gif|bmp|ico|mov|swf|pdf|zip|rar)$ {         try_files $uri =404;     }      location ~* \\.(htaccess|htpasswd|svn|git) {         deny all;     }      location \/api-location {         client_max_body_size 2000M;         alias  \/path\/to\/root\/frontend\/web;         try_files  $uri \/frontend\/web\/index.php?$args;          location ~* ^\/api-location\/(.+\\.php)$ {             try_files  $uri \/frontend\/web\/$1?$args;         }     } } <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0432\u0441\u0435 \u043d\u0430\u0448\u0435 API \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e location \/api- location. \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f angular $routeProvider:<\/p>\n<pre><code class=\"javascript\">app.config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider) { $routeProvider.     when('\/route1', {         templateUrl: '\/views\/route1.html',         controller: 'route1Ctrl'     }).     when('\/route2', {         templateUrl: '\/views\/route2.html',         controller: 'route2Ctrl'     })..     when('\/route3', {         templateUrl: '\/views\/route3.html',         controller: 'route3Ctrl'     }).     otherwise({         redirectTo: '\/route1'     });     \/\/ use the HTML5 History API     $locationProvider.html5Mode({         enabled: true,         requireBase: false     }); }]);  <\/code><\/pre>\n<p>  \u041d\u043e \u043a\u0430\u043a angular-\u0441\u0430\u0439\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0434\u0435\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f? \u0412 \u0433\u043e\u043b\u043e\u0432\u0443 \u0441\u0440\u0430\u0437\u0443 \u043f\u0440\u0438\u0448\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u043d\u0430\u0434\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0432, \u043d\u0430\u0448\u0435\u043b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e ?_escaped_fragment. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0442\u0438\u043f\u0430 <code>http:\/\/truemania.ru\/?_escaped_fragment<\/code> \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0434\u043b\u044f \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b.<\/p>\n<p>  \u041f\u0440\u0438 \u043d\u0435\u0434\u043e\u043b\u0433\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0435 \u043d\u0430\u0442\u043a\u043d\u0443\u043b\u0441\u044f \u043d\u0430 <a href=\"http:\/\/habrahabr.ru\/post\/187008\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a>, \u0433\u0434\u0435 \u0431\u044b\u043b \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0438\u043d\u0434\u0435\u043a\u0441\u0430\u0446\u0438\u0438 \u0434\u043b\u044f angular-\u0441\u0430\u0439\u0442\u043e\u0432, \u043a\u0430\u043a \u0440\u0430\u0437 \u0434\u043b\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u0430 nginx. \u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0435\u0449\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e location:<\/p>\n<pre><code class=\"nginx\">if ($args ~ &quot;_escaped_fragment_=(.*)&quot;) {    rewrite ^ \/snapshot${uri}; }  location \/snapshot {     proxy_pass http:\/\/help.truemania.ru\/snapshot;     proxy_connect_timeout  60s; } <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0434\u043e\u043c\u0435\u043d \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f, \u0433\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u043e\u0442\u0434\u0430\u0447\u0443 \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441 \u0442\u0438\u043f\u0430 <code>http:\/\/truemania.ru\/user\/50?_escaped_fragment_=&lt;\/\u0441ode&gt; \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 &lt;code&gt;http:\/\/help.truemania.ru\/snapshot\/user\/50<\/code>.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0441\u043b\u0435\u043f\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a\u043e\u0432\u043e\u043c\u0443 \u0431\u043e\u0442\u0443. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0430\u043c\u0438 \u043c\u0438\u043a\u0440\u043e\u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 <a href=\"http:\/\/schema.org\">schema.org<\/a>. \u041a\u0442\u043e \u043d\u0435 \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u043c\u0438\u0440\u043e\u043c \u0441\u0435\u043c\u0430\u043d\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438, \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u0441 <a href=\"http:\/\/habrahabr.ru\/company\/yandex\/blog\/211638\/\">\u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e sitemap \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0432 <a href=\"http:\/\/www.elisdn.ru\/blog\/38\/sitemap-for-yii-project\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u2014 \u0441\u043e\u0432\u0435\u0442\u0443\u044e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c. \u041d\u043e \u0436\u0430\u043b\u044c, \u0447\u0442\u043e \u0442\u0443\u0442 \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0432\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 Yii. Sitemap \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u043e\u0432\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0437\u0430\u043d\u043e\u0432\u043e, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0412\u044b\u0445\u043e\u0434 \u2014 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 sitemap \u0441 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c 10 \u043c\u0438\u043d\u0443\u0442, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f crontab. \u0421\u043e\u0432\u0441\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u043c\u0435\u043d\u0438\u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u044f \u043f\u043e\u043b\u0443\u0447\u0438\u043b \u0433\u043e\u0434\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f Yii2 console:<\/p>\n<pre><code class=\"php\">&lt;?php namespace console\\models;  use Yii; \/**  * @author ElisDN &lt;mail@elisdn.ru&gt;  * @link http:\/\/www.elisdn.ru  *\/  class DSitemap {     const ALWAYS = 'always';     const HOURLY = 'hourly';     const DAILY = 'daily';     const WEEKLY = 'weekly';     const MONTHLY = 'monthly';     const YEARLY = 'yearly';     const NEVER = 'never';      protected $items = array();      \/**      * @param $url      * @param string $changeFreq      * @param float $priority      * @param int $lastMod      *\/     public function addUrl($url, $changeFreq=self::DAILY, $priority = 0.5, $lastMod = 0)     {         $host = Yii::$app-&gt;urlManager-&gt;getBaseUrl();         $item = array(             'loc' =&gt; $host . $url,             'changefreq' =&gt; $changeFreq,             'priority' =&gt; $priority         );         if ($lastMod)             $item['lastmod'] = $this-&gt;dateToW3C($lastMod);          $this-&gt;items[] = $item;     }      \/**      * @param \\yii\\db\\ActiveRecord[] $models      * @param string $changeFreq      * @param float $priority      *\/     public function addModels($models, $changeFreq=self::DAILY, $priority=0.5)     {         $host = Yii::$app-&gt;urlManager-&gt;getBaseUrl();         foreach ($models as $model)         {             $item = array(                 'loc' =&gt; $host . $model-&gt;getUrl(),                 'changefreq' =&gt; $changeFreq,                 'priority' =&gt; $priority             );              if ($model-&gt;hasAttribute('create_date'))                 $item['lastmod'] = $this-&gt;dateToW3C($model-&gt;create_date);              $this-&gt;items[] = $item;         }     }      \/**      * @return string XML code      *\/     public function render()     {         $dom = new \\DOMDocument('1.0', 'utf-8');         $urlset = $dom-&gt;createElement('urlset');         $urlset-&gt;setAttribute('xmlns','http:\/\/www.sitemaps.org\/schemas\/sitemap\/0.9');         foreach($this-&gt;items as $item)         {             $url = $dom-&gt;createElement('url');              foreach ($item as $key=&gt;$value)             {                 $elem = $dom-&gt;createElement($key);                 $elem-&gt;appendChild($dom-&gt;createTextNode($value));                 $url-&gt;appendChild($elem);             }              $urlset-&gt;appendChild($url);         }         $dom-&gt;appendChild($urlset);          return $dom-&gt;saveXML();     }      protected function dateToW3C($date)     {         if (is_int($date))             return date(DATE_W3C, $date);         else             return date(DATE_W3C, strtotime($date));     } } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 action:<\/p>\n<pre><code class=\"php\">public function actionGetsitemap()     {         $sitemap = new DSitemap();          $sitemap-&gt;addModels(Model1::find()-&gt;active()-&gt;all(), DSitemap::HOURLY);         $sitemap-&gt;addModels(Model2::find()-&gt;all(), DSitemap::HOURLY);         $sitemap-&gt;addModels(Model3::find()-&gt;all(), DSitemap::HOURLY);          $path = \\Yii::getAlias(&quot;@frontend\/web&quot;) . DIRECTORY_SEPARATOR . &quot;sitemap.xml&quot;;         return file_put_contents($path, $sitemap-&gt;render());     } <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f crontab \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u0436\u0434\u044b\u0435 10 \u043c\u0438\u043d.<\/p>\n<p>  <code> *\/10 * * * * sh \/path\/to\/yii cron\/getsitemap &gt;&gt; \/path\/to\/log\/command_log\/getsitemap.log; <\/code><\/p>\n<p>  \u042d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435. \u041f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c sitemap \u0441 \u0431\u043e\u043b\u0435\u0435 \u0447\u0430\u0441\u0442\u044b\u043c \u0438\u043b\u0438 \u0431\u043e\u043b\u0435\u0435 \u0440\u0435\u0434\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0448\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u043d\u0430\u0434 \u043a\u0440\u0430\u0441\u0438\u0432\u044b\u043c \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0441\u0441\u044b\u043b\u043e\u043a \u0432 \u0441\u043e\u0446\u0441\u0435\u0442\u044f\u0445. \u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u0432 \u0442\u0435\u043c\u0435, \u2014 \u044d\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442 \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0438 <a href=\"http:\/\/ogp.me\/\">http:\/\/ogp.me\/<\/a>. \u041c\u0435\u043d\u044f \u043f\u043e\u0441\u0442\u0438\u0433\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u0440\u0430\u0437\u043e\u0447\u0430\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0431\u043e\u0442\u044b \u043d\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u044e\u0442 meta \u2014 \u0442\u0435\u0433\u0430:<\/p>\n<pre><code class=\"html\">&lt;meta name=&quot;fragment&quot; content=&quot;!&quot; \/&gt; <\/code><\/pre>\n<p>  \u041d\u0430 \u0434\u0430\u043d\u043d\u043e\u043c \u044d\u0442\u0430\u043f\u0435 \u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0437\u0430\u0441\u0442\u043e\u043f\u043e\u0440\u0438\u043b\u0441\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0440\u043d\u043e \u0432 \u043b\u043e\u0431 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c. \u042f \u0445\u043e\u0442\u0435\u043b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0431\u043e\u0442\u043e\u0432 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c, \u0447\u0442\u043e \u0437\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439 \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442. \u041f\u043e\u0433\u0443\u0433\u043b\u0438\u0432, \u044f \u043f\u0440\u0438\u043d\u044f\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b \u043f\u043e user-agent. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0434\u043b\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0435 user-agent, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u043c\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f\u043c\u0438.<\/p>\n<p>  \u041c\u043e\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f \u0434\u043b\u044f \u043e\u0442\u0434\u0430\u0447\u0438 \u0441\u0442\u0430\u0442\u0438\u043a\u0438 \u0431\u043e\u0442\u0430\u043c \u0441\u043e\u0446\u0441\u0435\u0442\u0435\u0439:<\/p>\n<pre><code class=\"nginx\"># \u0412\u043e\u0442 \u0442\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 user-agent \u2014 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0431\u043e\u0442 \u0441\u043e\u0446\u0441\u0435\u0442\u0435\u0439, \u043e\u0442\u0434\u0430\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u043a\u0443     if ( $http_user_agent ~* (facebookexternalhit|facebot|twitterbot|tinterest|google.*snippet|vk.com|vkshare) ){         rewrite ^ \/snapshot${uri};     } <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432 \u043c\u043e\u0438 \u0441\u043b\u0435\u043f\u043a\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0440\u0430\u0437\u043c\u0435\u0442\u043a\u0435 open graph.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u044f \u0437\u0430\u0445\u043e\u0442\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u0447\u0435\u043d\u044c \u0432\u044b\u0433\u043e\u0434\u043d\u044b\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u0430\u0445 websocet \u2014 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u043b\u043e \u0434\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0442\u0430\u043a\u0438\u0445 \u0437\u0430\u0434\u0430\u0447, \u043a\u0430\u043a \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 online\/offline \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0441\u0430\u043c\u0438 websocet \u0432\u0435\u0449\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0430\u044f \u0434\u043b\u044f PHP, \u043d\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u2014 <a href=\"http:\/\/socketo.me\/\">http:\/\/socketo.me\/<\/a>.<\/p>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a \u043c\u043d\u0435 \u044d\u0442\u0438 \u0441\u043e\u043a\u0435\u0442\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430 Yii2 \u0432 ubuntu. \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u043b \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440, \u0438 \u0432\u043e\u0442 \u043a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b action:<\/p>\n<pre><code class=\"php\">public function actionWebsocetaction()     {         $server = IoServer::factory(             new HttpServer(                 new WsServer(                     new UserOnline()                 )             ),             8099,             '127.0.0.1'         );          $server-&gt;run();     } <\/code><\/pre>\n<p>  \u041d\u0443, \u0438 \u0434\u0430\u043b\u0435\u0435 \u043f\u0440\u0438\u043b\u0430\u0433\u0430\u044e \u0441\u0430\u043c\u0443 \u043c\u043e\u0434\u0435\u043b\u044c UserOnline:<\/p>\n<pre><code class=\"php\">&lt;?php  namespace console\\models;  use Yii; use common\\modules\\core\\models\\User; use Ratchet\\MessageComponentInterface; use Ratchet\\ConnectionInterface; use yii\\web\\ServerErrorHttpException;  class UserOnline implements MessageComponentInterface {      \/**      * \u041b\u044e\u0431\u043b\u044e \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b, \u043d\u0435 \u043b\u044e\u0431\u043b\u044e \u0446\u0438\u0444\u0440\u044b      *\/     const USER_OFFLINE = 0;     const USER_ONLINE = 1; \t\/\/\u041f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u043d\u043e\u0432\u043e\u0433\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u0432 \u043b\u043e\u0433  resourceId     public function onOpen(ConnectionInterface $conn) {         echo &quot;New connection! ({$conn-&gt;resourceId})\\n&quot;;     } \t\/\/\u0415\u0441\u043b\u0438 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0441\u0442\u0430\u0432\u0438\u043c \u0434\u0430\u043d\u043d\u043e\u043c\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0441\u0442\u0430\u0442\u0443\u0441 online     public function onMessage(ConnectionInterface $from, $username) {         $model = UserOnlineConnections::findByUsername($username);         if(empty($model))         {             $model = new UserOnlineConnections(); \t\/\/\u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u043c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0432\u044b\u043f\u0438\u043b\u0438\u0442\u044c \u0438\u0445 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043a\u043e\u0439             $model-&gt;username = preg_replace('\/\\\\r\\\\n$\/', '', $username);             $model-&gt;conn_id = $from-&gt;resourceId;             if(!($model-&gt;validate() && $model-&gt;save()))                 throw new ServerErrorHttpException(json_encode($model-&gt;getErrors()));         }         else         {             $model-&gt;conn_id = $from-&gt;resourceId;             if(!($model-&gt;validate() && $model-&gt;save()))                 throw new ServerErrorHttpException(json_encode($model-&gt;getErrors()));         }          echo &quot;New user online $model-&gt;username \\n&quot;;          self::setUserStatus($username, self::USER_ONLINE);     } \t\/\/\u0415\u0441\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0437\u0430\u043a\u0440\u044b\u043b\u043e\u0441\u044c \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 offline     public function onClose(ConnectionInterface $conn) {         echo &quot;Close connection! ({$conn-&gt;resourceId})\\n&quot;;          $username = UserOnlineConnections::findByConnId($conn-&gt;resourceId)-&gt;username;         if($username) {             \/\/Set status offline             echo &quot;User offline $username \\n&quot;;              self::setUserStatus($username, self::USER_OFFLINE);         }     } \t\/\/\u0415\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u2014 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0432 offline     public function onError(ConnectionInterface $conn, \\Exception $e) {         $username = UserOnlineConnections::findByConnId($conn-&gt;resourceId)-&gt;username;         if($username) {             \/\/Set status offline             echo &quot;User offline $username \\n&quot;;              self::setUserStatus($username, self::USER_OFFLINE);              echo &quot;An error has occurred: {$e-&gt;getMessage()}\\n&quot;;              $conn-&gt;close();         }     }      \/**      * \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u043d\u0443\u0436\u043d\u044b\u0439 \u0441\u0442\u0430\u0442\u0443\u0441      * @param $username      * @param $status      * @return bool      * @throws ServerErrorHttpException      *\/     public function setUserStatus($username, $status)     {         $model = User::findByUsername($username);          if ($model) {             $model-&gt;online = $status;              if(!($model-&gt;validate() && $model-&gt;save()))                 throw new ServerErrorHttpException(json_encode($model-&gt;getErrors()));             return true;         }         if($status == self::USER_OFFLINE) {             UserOnlineConnections::deleteAll(                 &quot;username=&quot;.$username             );         }     } } <\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434 stderr \u0432 stdout, \u043d\u043e &#038;&gt; \u043f\u043e\u0447\u0435\u043c\u0443-\u0442\u043e \u043d\u0435 \u0445\u043e\u0442\u0435\u043b \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0448\u043b\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e nohup. \u0417\u0430\u043f\u0443\u0441\u043a \u0441\u043e\u043a\u0435\u0442\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u043b \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">nohup \/path\/to\/yii ws\/useronline &gt;&gt; \/path\/to\/log\/command_log\/useronline.log;  <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u043d\u0430\u0434\u043e \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u041d\u0435 \u043d\u0430\u0448\u0451\u043b \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u043e\u0433\u043e, \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u0436\u0434\u0443\u044e \u043c\u0438\u043d\u0443\u0442\u0443 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432 crontab. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u0437\u0430\u043d\u044f\u0442, \u0442\u043e \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442 (\u0432\u044b\u0439\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430), \u043d\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u0440\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u0435\u043d, \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0437\u0430\u043d\u043e\u0432\u043e.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e websocet \u043f\u0440\u043e\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e nginx. \u0418 \u0442\u0443\u0442 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e \u0431\u044b\u043b\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438:<\/p>\n<pre><code class=\"nginx\">upstream useronline {         server 127.0.0.1:8099; }  map $http_upgrade $connection_upgrade { \tdefault upgrade; \t''      close; } # \u0414\u043e\u0431\u0430\u0432\u043a\u0430 \u0432 \u0441\u0435\u043a\u0446\u0438\u044e server server { \t#ws proxy      location \/useronline {         proxy_set_header X-Real-IP $remote_addr;         proxy_set_header Host $host;         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;          proxy_http_version 1.1;         proxy_set_header Upgrade $http_upgrade;         proxy_set_header Connection $connection_upgrade;          proxy_pass http:\/\/useronline;     } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0432\u0435\u0431 \u0441\u043e\u043a\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u0435\u043d \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 ws:\/\/truemania.ru\/useronline.<\/p>\n<p>  \u0418 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435, \u0441 \u0447\u0435\u043c \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f (\u0438\u0437 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a web \u2014 \u0441\u0435\u0440\u0432\u0435\u0440\u0430) \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b https. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0431\u044b\u043b\u0430 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u2014 facebook \u0438 google+ \u0445\u043e\u0442\u0435\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043e\u0442\u0434\u0430\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e http, \u0438 \u0443\u043f\u043e\u0440\u043d\u043e \u043d\u0435 \u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u043f\u0440\u0435\u0432\u044c\u044e \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e \u2014 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440 \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043c\u0435\u0434\u0438\u0430 \u0444\u0430\u0439\u043b\u044b \u043f\u043e http:<\/p>\n<pre><code class=\"nginx\">server {     listen 80;     server_name truemania.ru;     root    \/path\/to\/frontend\/web;     location \/ {         return 301 https:\/\/$server_name$request_uri;  # enforce https     } #\u043e\u0442\u0434\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u043a\u0443 \u043f\u043e http     location ~* \\.(css|js|jpg|jpeg|png|gif|bmp|ico|mov|swf|pdf|zip|rar)$ {         try_files $uri =404;     } }  server {     charset utf-8;      listen 443 ssl;     ssl_certificate \/path\/to\/ssl\/truemania.crt;     ssl_certificate_key \/path\/to\/ssl\/truemania.key; } <\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e\u043c\u0435\u043d\u044f\u043b\u0441\u044f, \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a socet \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 wss:\/\/truemania.ru\/useronline.<\/p>\n<p>  \u041d\u0443 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0430\u043c \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u043e\u0441\u044c, \u0442\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u043b \u0441\u0430\u043c\u043e web \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 + backend, \u043e\u043f\u0438\u0448\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 angular \u2014 \u0442\u0430\u043a\u0438\u0435, \u043a\u0430\u043a \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438 \u043d\u0435 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 requireJS.       <\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/274867\/\"> http:\/\/habrahabr.ru\/post\/274867\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>       \u041d\u0430\u0447\u043d\u0443 \u0441 \u043f\u0440\u0435\u0434\u044b\u0441\u0442\u043e\u0440\u0438\u0438 \u0441\u0430\u043c\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041c\u044b\u0441\u043b\u044c \u043f\u0440\u0438\u0448\u043b\u0430 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e \u2014 \u043c\u043d\u0435 \u044f\u0432\u043d\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434 \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u043c\u0438 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438. \u0412\u043e\u0442 \u0438 \u0440\u0435\u0448\u0438\u043b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u0430\u043b, \u0433\u0434\u0435 \u044f \u0441\u043c\u043e\u0433 \u0431\u044b \u0441\u0442\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u0443\u044e \u043c\u043e\u0442\u0438\u0432\u0430\u0446\u0438\u044e, \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e \u0440\u0438\u0441\u043a\u0443\u044f \u0440\u0435\u043f\u0443\u0442\u0430\u0446\u0438\u0435\u0439 \u0438 \u0434\u0435\u043d\u044c\u0433\u0430\u043c\u0438.<\/p>\n<p>  \u041d\u0443, \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0439\u0434\u0443 \u043a \u0434\u0435\u043b\u0443. \u0422\u0435\u043c\u0430 \u043e\u0431\u0448\u0438\u0440\u043d\u0430\u044f, \u043d\u043e \u044f \u043d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0443 \u043c\u0435\u043d\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u0443 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u043f\u043b\u044b\u043b\u0438 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u042f \u0431\u0443\u0434\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0435\u0440\u0432\u043e\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0451 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 angular. \u0414\u0430, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u0435 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u0441\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u0439\u0442\u0438 \u043e\u0442\u0432\u0435\u0442\u044b \u043d\u0430 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0438\u0445 \u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u0434\u0430\u043d\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 \u0432 \u043e\u0434\u043d\u043e\u043c \u0446\u0438\u043a\u043b\u0435 \u0441\u0442\u0430\u0442\u0435\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-271902","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=271902"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/271902\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=271902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=271902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=271902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}