yii2 and load balancing
<p>I'm working on a PHP Yii2 application. I have a strange problem with yii2 ,here is my problem.</p>

<p>As we known, there is a web\assets folder in Yii2 project and it will load it's own asset bundle,but when configuring load balance , I found that  chrome's developer tools console throw some errors below:</p>

<pre><code>http://firekylin.eastasia.cloudapp.azure.com/assets/fde0fce1/css/bootstrap.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://firekylin.eastasia.cloudapp.azure.com/assets/ebd0699a/css/AdminLTE.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://firekylin.eastasia.cloudapp.azure.com/assets/5e97633a/jquery.js Failed to load resource: the server responded with a status of 404 (Not Found)
yii.js:464 Uncaught ReferenceError: jQuery is not defined(…)
http://firekylin.eastasia.cloudapp.azure.com/assets/14e563af/yii.validation.js Failed to load resource: the server responded with a status of 404 (Not Found)
http://firekylin.eastasia.cloudapp.azure.com/assets/fde0fce1/js/bootstrap.js Failed to load resource: the server responded with a status of 404 (Not Found)
yii.activeForm.js:14 Uncaught TypeError: Cannot read property 'fn' of undefined(…)
http://firekylin.eastasia.cloudapp.azure.com/assets/fde0fce1/js/bootstrap.js Failed to load resource: the server responded with a status of 404 (Not Found)
app.min.js:13 Uncaught Error: AdminLTE requires jQuery(…)
index.php:555 Uncaught ReferenceError: jQuery is not defined(…)
http://firekylin.eastasia.cloudapp.azure.com/assets/88d3a068/css/font-awesome.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
http://firekylin.eastasia.cloudapp.azure.com/assets/ebd0699a/css/skins/_all-skins.min.css Failed to load resource: the server responded with a status of 404 (Not Found)
</code></pre>

<p>It can't find js,css file when using the load balance ip to visit,but once I use the ip of the server where there exactly is a Yii2 application running,the web page will load js,css file successfully:</p>

<p><a href="https://i.stack.imgur.com/Ym5Qs.png" rel="nofollow noreferrer">left one is using load balance server to visit and right one is using Yii2 server to visit</a></p>

<p>There are two servers exactly running Yii2 and they both have their own web\assets folder and have different caches:</p>

<p><a href="https://i.stack.imgur.com/2QjJT.png" rel="nofollow noreferrer">web\assets folders in two Yii2 servers</a></p>

<p>I found that once I stop one of the Yii2 Server,the load balance server will work successfully.Therefore,I guess maybe the problem result from Yii2's web\assets folder.From the two pictures above we can find that Yii2 use md5 to rename the folders in it,so maybe it was because the two Yii2 servers' web\assets folders have different named child-folders that makes the problem happened?</p>

<p>However,I've try to solve the problem with below codes:</p>

<pre><code>&lt;?php

$params = require(__DIR__ . '/params.php');

$config = [
'id' =&gt; 'basic',
'defaultRoute'=&gt;'firekylin',
'basePath' =&gt; dirname(__DIR__),
'bootstrap' =&gt; ['log'],
'components' =&gt; [

    'view' =&gt; [
        'theme' =&gt; [
            'pathMap' =&gt; [
                '@app/views' =&gt; '@app/views/dmstr/yii2-adminlte-asset/example-views/yiisoft/yii2-app'
            ],
        ],
    ],

    'assetManager' =&gt; [
        'class' =&gt; 'yii\web\AssetManager',
        'forceCopy' =&gt; true,
    ],


    'request' =&gt; [
        // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
        'cookieValidationKey' =&gt; '2MhlyGaaGs_uqt_apwy1jLahR_wZ8dBv',

        'parsers' =&gt; [
            'application/json' =&gt; 'yii\web\JsonParser',
            'text/json' =&gt; 'yii\web\JsonParser',
        ]
    ],
    'cache' =&gt; [
        'class' =&gt; 'yii\caching\FileCache',
    ],
    'user' =&gt; [
        'identityClass' =&gt; 'app\models\OriginUser',
        'enableAutoLogin' =&gt; true,
    ],
    'errorHandler' =&gt; [
        'errorAction' =&gt; 'site/error',
    ],
    'mailer' =&gt; [
        'class' =&gt; 'yii\swiftmailer\Mailer',
        // send all mails to a file by default. You have to set
        // 'useFileTransport' to false and configure a transport
        // for the mailer to send real emails.
        'useFileTransport' =&gt; true,
    ],
    'log' =&gt; [
        'traceLevel' =&gt; YII_DEBUG ? 3 : 0,
        'targets' =&gt; [
            [
                'class' =&gt; 'yii\log\FileTarget',
                'levels' =&gt; ['error', 'warning'],
            ],
        ],
    ],
    'db' =&gt; require(__DIR__ . '/db.php'),
    /*
    'urlManager' =&gt; [
        'enablePrettyUrl' =&gt; true,
        'showScriptName' =&gt; false,
        'rules' =&gt; [
        ],
    ],
    */
],
'params' =&gt; $params,
];

if (YII_ENV_DEV) {
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = [
    'class' =&gt; 'yii\debug\Module',
];

$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
    'class' =&gt; 'yii\gii\Module',
];
$config['components']['assetManager']['forceCopy'] = true;
}

return $config;
</code></pre>

<p>and</p>

<pre><code>public function beforeAction($action){

        Yii::$app-&gt;assetManager-&gt;forceCopy = YII_DEBUG;

    return parent::beforeAction($action);
}
</code></pre>

<p>I try to use assetManager  or</p>

<pre><code>$config['components']['assetManager']['forceCopy'] = true;
</code></pre>

<p>in config\web.php or function beforeAction in my own controller to forbid assets folder,but it doesn't work.Is there any way to solve the problem?</p>