Thursday, January 27, 2022

How To Install Plex Media Server With Nginx on Rocky Linux 8.5

 in This Tutorial you will learn " How To Install Plex Media Server With Nginx on Rocky Linux 8.5"
    
Plex is a streaming service that is based on a client-server architecture. Homepage - https://www.plex.tv/
_________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y

nano /etc/yum.repos.d/plex.repo
[Plex]
name=Plex
baseurl=https://downloads.plex.tv/repo/rpm/$basearch/
enabled=1
gpgkey=https://downloads.plex.tv/plex-keys/PlexSign.key
gpgcheck=1

dnf install plexmediaserver nginx -y
systemctl enable plexmediaserver ; systemctl restart plexmediaserver ; systemctl status plexmediaserver
mkdir -p /opt/plexmedia/{movies,series} ; chown -R plex: /opt/plexmedia
nano /etc/nginx/nginx.conf
server_names_hash_bucket_size 64;

nano /etc/nginx/conf.d/plex.conf
upstream plex_backend {
        server 127.0.0.1:32400;
        keepalive 32;
}
server {
        listen 80;
        server_name plex.example.com;
        send_timeout 100m;
        gzip on;
        gzip_vary on;
        gzip_min_length 1000;
        gzip_proxied any;
        gzip_types text/plain text/css text/xml application/xml text/javascript application/x-javascript image/svg+xml;
        gzip_disable "MSIE [1-6]\.";

        client_max_body_size 100M;
       #Forward real ip and host to Plex
        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 X-Forwarded-Proto $scheme;
        proxy_set_header Sec-WebSocket-Extensions $http_sec_websocket_extensions;
        proxy_set_header Sec-WebSocket-Key $http_sec_websocket_key;
        proxy_set_header Sec-WebSocket-Version $http_sec_websocket_version;
       #Websockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
      #Buffering off send to the client as soon as the data is received from Plex.
        proxy_redirect off;
        proxy_buffering off;

        location / {
                proxy_pass http://plex_backend;
        }
}

nginx -t
nano /etc/hosts
192.168.1.60    plex.example.com
systemctl restart nginx ; systemctl status nginx

firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload
plex.example.com
__________________________________________________________________________________________

No comments:

Post a Comment