简体   繁体   中英

Nginx not loading JS, CSS correctly

I am trying to reproduce https://forum.elitegaming.me/ in Nginx. However, the server is not parsing JS and CSS files correctly. PHP and HTML seem to load correctly. I have proxy_pass and testcookie-nginx-module loaded.

Here is my nginx.conf:


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {
    #default config, module disabled
    testcookie off;

    #setting cookie name
    testcookie_name BPC;

    #setting secret
    testcookie_secret FAGasffasjh3ENGN89346834tgj843g82fm832f83;

    #setting session key
    testcookie_session $remote_addr;

    #setting argument name
    testcookie_arg attempt;

    #setting maximum number of cookie setting attempts
    testcookie_max_attempts 3;

    #setting fallback url
    testcookie_fallback https://$host$request_uri;

    #configuring whitelist
    testcookie_whitelist {
        8.8.8.8/32;
        157.240.2.35/32;
    }

    #setting redirect via html code
    testcookie_redirect_via_refresh on;

    #enable encryption
    testcookie_refresh_encrypt_cookie on;

    #setting encryption key
    testcookie_refresh_encrypt_cookie_key deadbeedfeadbeefdeadbeefdeadbeef;

    #setting encryption iv
    testcookie_refresh_encrypt_cookie_iv deadbeedfeadbeefdeadbeefdeadbeef;

    #setting response template
    testcookie_refresh_template '<html>
<head>
    <meta charset= "utf-8">
    <meta http-equiv= "x-ua-compatible" content= "ie=edge">
    <meta name= "viewport" content= "width=device-width,initial-scale=1,shrink-to-fit=no">
    <title>Checking your browser..</title>
    <link href= "https://fonts.googleapis.com/css?family=Poppins" rel= "stylesheet">
    <link href= "/style.css" rel= "stylesheet">
</head>

<body>
    <header style="display:none;"></header>
    <div class="loader is-active" id="loading-content">
        <div class="wrapper">
            <main class="main">
                <div class="validation">
                    <div class="loader__items"></div>
                    <div class="lds-ellipsis">
                        <div></div>
                        <div></div>
                        <div></div>
                        <div></div>
                    </div>
                    <h2>This website is using traffic filtering to protect against malicious attacks.</h2>
                    <p>We are evaluating your browser, you will be redirected shortly.</p>
                </div>
            </main>
            <footer class="footer">
                <p>DDoS protection proudly powered by <span class="purple">Gari Web</span></p>
            </footer>
        </div>
    </div>

    <script type="text/javascript" src="/aes.min.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f<d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("deadbeedfeadbeefdeadbeefdeadbeef"),b=toNumbers("deadbeedfeadbeefdeadbeefdeadbeef"),c=toNumbers("$testcookie_enc_set");document.cookie="BPC="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/";location.href="$testcookie_nexturl";</script>
</body>

</html>';

    server {
        listen 80;

        location = /aes.min.js {
            gzip  on;
            gzip_min_length 1000;
            gzip_types      text/plain;
            root /var/www/html;
        }

        location = /style.css {
            gzip  on;
            gzip_min_length 1000;
            gzip_types      text/plain;
            root /var/www/html;
        }

        location / {
            #enable module for specific location
            testcookie on;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header        Referer         "http://ip-of-web-space";
            proxy_pass http://ip-of-web-space; # ip of web space
        }
    }

    server {
        listen 443;

        location = /aes.min.js {
            gzip  on;
            gzip_min_length 1000;
            gzip_types      text/plain;
            root /var/www/html;
        }

        location = /style.css {
            gzip  on;
            gzip_min_length 1000;
            gzip_types      text/plain;
            root /var/www/html;
        }

        location / {
            #enable module for specific location
            testcookie on;
            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header        Referer         "http://ip-of-web-space";

            proxy_pass http://ip-of-web-space; # ip of web space
        }

    }
}

URL of website: https://forum.elitegaming.me What happens: Image

On some browsers its loading half, but on Tor it doesnt load any css, js, etc.. files, only html, php.

Thanks!

What is the reason that you use Tor? Tor blocks Javascript and other files loading by default for security reasons.

You should use a 'normal' Browser like Chrome or Firefox...Then it will work probably.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM