Jump to content

nginx reverse proxy too slow


z3ndra

Recommended Posts

z3ndra

hello I configured a proxy server via nginx to access emby, everything works perfectly, just a flat, the loading time of the site is hyper long. would you have a solution to settle this? thank you ;)

Link to comment
Share on other sites

Hmm, someone else mentioned this recently and it turned out to be caused by their nginx config if I'm not mistaken.

Link to comment
Share on other sites

cuzz1369

Nginx works perfectly for me. No delay. It is your settings.

 

Sent from my SM-G965W using Tapatalk

Link to comment
Share on other sites

z3ndra

can you give me your settings please ?

 

because I do not know what's wrong

Edited by z3ndra
Link to comment
Share on other sites

z3ndra

I make a example with a vps .

 

#nginx.conf


user www-data;
worker_processes auto;
pid /run/nginx.pid;

events {
        worker_connections 1024;
        # multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile off;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
 types_hash_max_size 2048;
        # server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

       gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        # gzip_proxied any;
        # gzip_comp_level 6;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        # gzip_types text/plain text/css application/json application/javascrip$

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}


#mail {
#       # See sample authentication script at:
#       # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
#       # auth_http localhost/auth.php;
#       # pop3_capabilities "TOP" "USER";
#       # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
#       server {
#               listen     localhost:110;
#               protocol   pop3;
#               proxy      on;
#       }
#
#       server {
#               listen     localhost:143;
#               protocol   imap;
#               proxy      on;
#       }
#}










#proxy.conf


proxy_redirect          off;
proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size    10m;
client_body_buffer_size 128k;
client_header_buffer_size 64k;
proxy_connect_timeout   90;
proxy_send_timeout      90;
proxy_read_timeout      90;
proxy_buffer_size   16k;
proxy_buffers       32   16k;
proxy_busy_buffers_size 64k;



#sites-enabled#

server {
        listen   80;
        server_name     login-moovix.fr;
        return 301 https://$host$request_uri;


}

server {
        listen  443;
        server_name     login-moovix.fr;
        ssl on;
ssl_session_timeout 30m;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
        ssl_certificate /etc/letsencrypt/live/login-moovix.fr/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/login-moovix.fr/privkey.pem;
ssl_session_cache shared:SSL:10m;

add_header X-Xss-Protection "1; mode=block" always;
                add_header X-Content-Type-Options "nosniff" always;
                add_header Strict-Transport-Security "max-age=2592000; includeS$
                add_header X-Frame-Options "SAMEORIGIN" always;
                proxy_hide_header X-Powered-By;
                add_header 'Referrer-Policy' 'no-referrer';
                add_header Content-Security-Policy "frame-ancestors mydomain.co$
        location / {
                 proxy_pass       https://164.132.43.26:8920/;
proxy_set_header Range $http_range;
                proxy_set_header If-Range $http_if_range;
                proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        #Next three lines allow websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
}
}

}
}



 

Link to comment
Share on other sites

pir8radio

You had no admin password on your account.....  I added one and will PM you the password...   Sorry, but anyone could have deleted your stuff...   Be careful about posting domain names and IP's in your examples....   emby was looking to fix that not sure how it let you, maybe an older version i didn't look.

 

Check out this config:    https://emby.media/community/index.php?/topic/48236-setting-up-emby-behind-a-reverse-proxy-nginx/?p=457670

 

My example has all of your config files in one config   "nginx.conf"    Im not a fan of all the separate configs its messy...       I saw your nginx was slow..     Look into HTTP2 as well "listen 443 ssl http2;"   save your original nginx.conf, and copy mine, change the stuff to match your setup "logging, proxy_pass, etc" see if it works any better.     

Edited by pir8radio
Link to comment
Share on other sites

z3ndra

@@pir8radio

 

how should I do in your configuration, if I want to do a temporary redirection to an external url, for example when I cut the emby service in case of maintenance and I want to redirect the domain name to an external page?

thank you

Link to comment
Share on other sites

pir8radio

@@pir8radio

 

how should I do in your configuration, if I want to do a temporary redirection to an external url, for example when I cut the emby service in case of maintenance and I want to redirect the domain name to an external page?

 

thank you

 

 

You can do something like this:

location / {
     if (-f $document_root/maintenance.html) {
     proxy_pass https://ebay.com/;  #trailing slash after external maintenance url
     }
     proxy_pass https://emby.server.ip:8096; #emby server url

if you put an html file called "maintenance.html" in the root directory on your nginx server it will switch to maintenance mode. 

 

I didn't test this, soooo..  let me know if it works lol     :)

Edited by pir8radio
Link to comment
Share on other sites

z3ndra

I added $uri after the address otherwise I had an error, but the redirection does not work because I always fall on emby by typing the address, despite that I created a html file in the directoryroot....

Link to comment
Share on other sites

pir8radio

I added $uri after the address otherwise I had an error, but the redirection does not work because I always fall on emby by typing the address, despite that I created a html file in the directoryroot....

 

Ok thats what i was thinking might happen, ill whip up a working script for ya' today, Off to work right now.

Link to comment
Share on other sites

pir8radio

Yes i want it. Thank u so much

 

the hard part is trying to do a second proxy pass with an IF,   if's usually are bad in configs..   Do you just want a static maintenance page shown, or do you want to redirect to another website?

Link to comment
Share on other sites

pir8radio

I want redirect to another site please

 

 

try this for me...   Again, didnt test lol     same deal if the maintenance.html file is in your nginx root it should redirect.  just remove the file from the root to go back to normal.

location / {
     if (-f $document_root/maintenance.html) {
     return 302 http://www.example.com; #Redirect url
     }
     proxy_pass https://emby.server.ip:8096; #emby server url
Edited by pir8radio
Link to comment
Share on other sites

z3ndra

thank u, I do not have an error. by cons or I have to put the file maintenance.html? because I am in the directory / etc / nginx / but the redirection does not work

 

in var/www/html it s the same issue

Edited by z3ndra
Link to comment
Share on other sites

pir8radio

Do you host more than one vhost on your nginx? smells like an SNI issue.

 

you talking about the original issue, or the maintenance mode?    Original issue is fixed, he probably should have marked the post as answered...   :)

Link to comment
Share on other sites

  • 2 years later...
rodainas
3 hours ago, Ferdi82 said:

@pir8radio It seems the link to the Nginx configuration you posted before does not work anymore. Can you please share it again?

 

 

Check his newest one

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...