Dtech 0 Posted December 30, 2020 Posted December 30, 2020 so this is probably out there somewhere but i am having a hard time finding it. So i have a server running Nginx i can connect to it with most apps though the CDN but some do not connect and the server is just forwarding to the real ip not using the CDN so it cant cache the imgs that are on the server. meaning slower load times for the pics. My goal is to have all apps use the reverse proxy though NGINX, using the cdn with cloudflare, having it forward videos for better peering and cache imgs for faster load times. partial logfile https://pastebin.com/THxByX7E not sure if it will help.
Luke 42078 Posted December 30, 2020 Posted December 30, 2020 Hi there, I would suggest comparing your nginx setup to that of @pir8radio
pir8radio 1312 Posted December 31, 2020 Posted December 31, 2020 (edited) On 12/29/2020 at 7:43 PM, Dtech said: so this is probably out there somewhere but i am having a hard time finding it. So i have a server running Nginx i can connect to it with most apps though the CDN but some do not connect and the server is just forwarding to the real ip not using the CDN so it cant cache the imgs that are on the server. meaning slower load times for the pics. My goal is to have all apps use the reverse proxy though NGINX, using the cdn with cloudflare, having it forward videos for better peering and cache imgs for faster load times. partial logfile https://pastebin.com/THxByX7E not sure if it will help. you are explaining two different issues... the image cache issue is probably due to emby not having an extension on their image files... you will need a page rule in cloudflare like this: emby.yourdomein.com/emby/Items/*/Images/* Cache Level: Cache Everything, Edge Cache TTL: a month as for apps not working its probably due to you using a sub directory and not a sub domain.. always causes issues with reverse proxy's and application servers you can't recode, if you are not really really good with a reverse proxy. maybe i'm wrong, compare the below config... i use cloudflare with all apps no issues. Also make sure your emby server "Network" settings look like this: The first line can be ignored, my server is in a data center, so I needed to add a network address that didn't exist so EVERYTHING was external to my server. Make sure your "External Domain" is set to whatever your real domain name is. Let Reverse proxy handle encryption Edited December 31, 2020 by pir8radio
Dtech 0 Posted December 31, 2020 Author Posted December 31, 2020 Is my reverse proxy kind of messy but works mostly.. ``location /emby/ { rewrite /emby/(.*) /$1 break; include /etc/nginx/snippets/proxy.conf; proxy_pass http://127.0.0.1:8096/; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; proxy_set_header X-Real-IP $remote_addr; 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; includeSubdomains" always; 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 cdn.louthan.win;"; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; }`` as for the settings in network all are the same except the http port as i just left that one as default android and roku both work with current settings the ones that dont work is amazon firestick and the windows application.
Dtech 0 Posted December 31, 2020 Author Posted December 31, 2020 (edited) 52 minutes ago, Luke said: Did you compare to his? Yes still waiting for a reply to see if he can help fine tune it. The cacheing is working now. Now my only problem is that 2/4 apps don't support the sub-directory which sucks but is not the end of the world. I don't want to switch over to a strictly subdomain (mostly because I have other things running on server that I don't want to break & I'm not king of nignx and my attempts to make them work together failed so bad) Now I can't understand why the emby log says something odd but I think it's not breaking the caching so I'm not % sure it's a problem 2020-12-31 06:14:15.089 Info Server: http/1.1 GET http://cdn.louthan.win/Items/146415/Images/Primary?maxHeight=270&maxWidth=180&tag=4148727345be3425fe7b971eec1d97e7&quality=90. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0 2020-12-31 06:14:15.089 Info Server: http/1.1 GET http://cdn.louthan.win/Items/146416/Images/Primary?maxHeight=270&maxWidth=180&tag=29f2a5993a7c31a01719105ced006c92&quality=90. UserAgent: Mozilla/5.0 Should say cdn.louthan.win/emby so again not supporting the sub-directory. Edited December 31, 2020 by Dtech
pir8radio 1312 Posted January 1, 2021 Posted January 1, 2021 (edited) 22 hours ago, Dtech said: Yes still waiting for a reply to see if he can help fine tune it. The cacheing is working now. Now my only problem is that 2/4 apps don't support the sub-directory which sucks but is not the end of the world. I don't want to switch over to a strictly subdomain (mostly because I have other things running on server that I don't want to break & I'm not king of nignx and my attempts to make them work together failed so bad) Now I can't understand why the emby log says something odd but I think it's not breaking the caching so I'm not % sure it's a problem 2020-12-31 06:14:15.089 Info Server: http/1.1 GET http://cdn.louthan.win/Items/146415/Images/Primary?maxHeight=270&maxWidth=180&tag=4148727345be3425fe7b971eec1d97e7&quality=90. UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0 2020-12-31 06:14:15.089 Info Server: http/1.1 GET http://cdn.louthan.win/Items/146416/Images/Primary?maxHeight=270&maxWidth=180&tag=29f2a5993a7c31a01719105ced006c92&quality=90. UserAgent: Mozilla/5.0 Should say cdn.louthan.win/emby so again not supporting the sub-directory. this is why you have issues with sub directory... some legitimate emby files are located at domain.com/emby/xxxxx and some are just domain.com/xxxxx right now your nginx config is stripping off the /emby/ also some of the apps request files directly at domain.com/files and don't always add the /emby/ automatically... your nginx with subdirectory will ignore those and try to server the file from your root domain.com. I run quite a few services all sub domain.. you can do both, the "server" block "server_name" has to be matched before the location within that server block will work.. so you can leave what you have now then add a new server block at the end of your config before the last } close.. make the server name emby.yourdomain.com using as much of my test config as you can and test it. Your CDN will also need a cname added for "emby.domain.com" or "emby.*" however your CDN works. also you said you were using cloudflare... looks like you are using a different CDN? also your ip and stuff is exposed in your current setup... if it was your plan to hide this then you are doing it wrong. Edited January 1, 2021 by pir8radio 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now