If you have not already, we suggest setting your Plex username to something else rather than email which is displayed on your posts in forum. You can change the username at https://app.plex.tv/desktop#!/account
Welcome to our forums! Please take a few moments to read through our Community Guidelines (also conveniently linked in the header at the top of each page). There, you'll find guidelines on conduct, tips on getting the help you may be searching for, and more!

A guide to how I got PlexConnect running on OS X Server (10.7)

sebsebsebseb Posts: 36Members ✭✭
edited December 2013 in PlexConnect (Apple TV 2 & 3)

Finally I got PlexConnect running on my Mac Mini with OS X Server =D
Lion 10.7
(Also confirmed to work on Mountain Lion 10.8 and Mavericks 10.9, I've updated the guide accordingly where there're differences.)

Updated by f00b4r on 16 December 2013 - Added fix for "/" issue and removed automator applet details as launchctl is now supported in code (see "support/osx" sub folder)

Update, june 16 - The latest version of PlexConnect and the updated settings file has made it easier for us. Along with the addition to our site config from ignipotentis (#29) there's no need to edit any of the PlexConnect scripts anymore which makes our future updates much easier =)

Note there is an alternate method here by Xwk88 that uses a virtual interface rather than vhosts here (note the caveats though):

 

EDIT: The issue about having to start  PlexConnect first using Xwk88's method has been resolved in this post.

I use my own DNS service and I can still use the web server and host other webpages while PlexConnect is running.

So here's how:

1. Download a fresh copy of PlexConnect.

2. Run the PlexConnect.py script once in the terminal to create the settings.cfg file. Then hit CTRL+enter to end the script

3. Edit the settings.cfg file,
set ip_pms to the ip of your PlexMediaServer
set ip_dnsmaster to the ip of your DNS-server (in my case these two are the same)
set enable_dnsserver to "false" (without the quotes)
set port_webserver to "9999" (without the quotes)

Skärmavbild 2013-06-16 kl. 20.14.11.png


4. Now we have to edit the file webserver.py. First we change the port it's working on from 80 (as this conflicts with our own web server). I changed it to port 9999.

5. The second change to webserver.py is made to stop the plexconnect web server from checking if it's really an appletv it's serving or any other device. As we later on will forward and return appletv-requests from our webserver to the plexconnect webserver we don't want evil error 403-messages we want nice XML-files to serve our apple-tv with
Replace the lines I've selected in the picture with if self.headers.startswith(""):
Before:
After:

6. That's it with the plexconnect script. Fire it up and make sure everything works as it's supposed to.
You should get the message "WebServer : WebServer: Serving HTTP on YOUR_IP_ADDRESS port 9999."
If you open safari and enter http://localhost:9999 the result is supposed to be an error 403 page which says your device isn't served by PlexConnect. (We'll deal with that later)

PlexConnect is working as it's supposed to =) Lets move on!


7. Now it's time to fix our DNS-server. As I use Lion server I use Server Admin. DNS is integrated in Server App if you use 10.8. (Setting up DNS in Mavericks Server developer preview - read notes in Nevirs' post #96)

Add a new zone and machine record as the image shows. trailers.apple.com is where the ATV makes its request. 10.0.1.4 is the IP of my server, just replace it with whatever fits your server and hit Save.
Skärmavbild 2013-06-12 kl. 19.44.12.png


8. Open server app, go to the web section. Click the plus icon and enter settings as shown in the picture. trailers.apple.com and port 80. Then I just created a folder named trailers to use as document root. Click done! Now we have the dns ready and a website to serve the apple TV with the information needed to use plexconnect.
Skärmavbild 2013-06-12 kl. 19.53.15.png


9. If you open safari you can still use your all other web sites. If you enter trailers.apple.com you will get a no access message as there are nothing present in the folder you choose to use for keeping the files in.

Our DNS and the website that's supposed to serve the ATV is working! Now it's time to connect our website with the plex connect webserver running on port 9999.

10. To make the connection between trailers.apple.com and the webserver we have to edit the config file for the website we just created in the server app.

Open up terminal and cd to "/etc/apache2/sites" (OS X Server 10.7) or "/Library/Server/Web/Config/apache2/sites/" (OS X Server 10.8), then ls in the list you will find a file named "0000_any_80_trailers.apple.com.conf" this is the file we have to edit.

enter the command sudo vi 0000_any_80_trailers.apple.com.conf hit enter and type in your password then enter again.
move the cursor down to the bottom of the file between the </directory> and </VirtualHost> tags. Hit the "i" button on your keyboard and enter the text marked in grey in the picture.


RequestHeader set User-Agent AppleTV
ProxyRequests off
AllowEncodedSlashes NoDecode
ProxyPass / http://trailers.apple.com:9999/ nocanon
ProxyPassReverse / http://trailers.apple.com:9999/

Be sure to get all the / right and don't forget the ones at the end of the lines otherwise this won't work.
When you're finished with the text hit "esc" and then "ZZ" (note Z not z).
Skärmavbild 2013-06-16 kl. 20.30.55.png


What we use here is a reverse proxy. When a request arrives to our server - trailers.apple.com at port 80 these lines tells apache that we want another resource to serve this request in your case the plexconnect web server which is running at port 9999. So apache forwards the request for trailers.apple.com gets an answer from plexconnect and nicely returns it back to our AppleTV which has no clue it actually got its XML file from the server at port 9999 instead of port 80 as it requested ;-)

10. Go back to the server app and make sure to reboot your web server. (Turn off and then on again)

11. Now you can try the setup by entering trailers.apple.com in safari and the result should be a blank page which has all the XML in it if you view the source.

If this is the case everything is working as it should, PlexConnect is running on your server at the same time as you can host your own dns and websites without any interruptions.
Skärmavbild 2013-06-12 kl. 19.40.53.png


12 It's time to move over to the ATV. Edit DNS-settings in the ATV and point them to your server (dns-server) In my case I use my OS X server as the standard DNS-server so I left the default dns-setting in my ATV. But just change it to the right IP for your config.

13. Go back to the home screen and enter trailers. Voila PlexConnect running on OS X Server =)

14. If you want to have PlexConnect automatically start at boot then look in the "support/OSX" folder to have launchctl automatically start it without requiring an admin password to be entered each time or to saved anywhere.

That's it!!! :-D
«13456710

Comments

  • Alan.CarslawAlan.Carslaw Posts: 100Members, Plex Pass Plex Pass

    Very good guide - thanks :) 

  • Alan.CarslawAlan.Carslaw Posts: 100Members, Plex Pass Plex Pass

    Off topic how do you like OSX Server, have been looking into possibly purchasing, as have multiple apple devices in the home.... currently I have PMS and plexconnect running on Ubuntu 

  • MichielMichiel Plex Ninja Posts: 871Members, Plex Pass, Plex Ninja Plex Ninja

    Great guide, great job!

  • baabaa Posts: 3,954Members, Plex Pass, Forum Moderator Forum Mod

    Nice guide... we should add it to our little Wiki :-)

    ...and I spent hours and hours to get this DNSServer to work. :-D

    Plex @ aTV - think different: PlexConnect

    -> the missing link between Plex Media Server and your AppleTV - 2 or 3, jailbroken or not.

    plex forums: [PlexConnect] -- github: [latest Sources], [Wiki] -- donations (paypal): [US-$][EUR]

  • morten@lamo.dkmorten@lamo.dk Posts: 5Members, Plex Pass Plex Pass

    Hi, 

    Thanks for this guide.

    I am running Mountain Lion.

    I cant seem to complete step 10.

    I cant get to  /etc/apache2/sites

    (I can get to /etc/apache2 - but there is no sites and hence no 0000_any_80_trailers.apple.com.conf 

    can you help me ?

  • sebsebsebseb Posts: 36Members ✭✭
    morten@lamo.dk wrote on June 12 2013, 8:36 PM: »

    Hi, 

    Thanks for this guide.

    I am running Mountain Lion.

    I cant seem to complete step 10.

    I cant get to  /etc/apache2/sites

    (I can get to /etc/apache2 - but there is no sites and hence no 0000_any_80_trailers.apple.com.conf 

    can you help me ?

    seams like they moved the apache config files in 10.8.

    Try this path instead and you should find the files we're looking for =)

    /Library/Server/Web/Config/apache2/sites/

  • sebsebsebseb Posts: 36Members ✭✭
    edited June 2013
    AlanCarslaw wrote on June 12 2013, 6:51 PM: »

    Off topic how do you like OSX Server, have been looking into possibly purchasing, as have multiple apple devices in the home.... currently I have PMS and plexconnect running on Ubuntu 

    I've got a quite old mac mini which can't be upgraded to 10.8 so I just bought it for Lion when it was released to try it out. It can be quite tricky to get it to work as you want all the times. There are only very basic settings in the server app for 10.7. Have heard it's much better in 10.8.

    So far I've used it for file sharing in my home network which works very well.

    As we have a few Macs at home the TimeMachine Server is great too.

    Just these 2 parts of it is well worth the money for the server addition.

    Now I'm waiting for an upgraded mac mini with the new intel core processors and of course Mavericks then I hope to get more services up and running. 

  • sebsebsebseb Posts: 36Members ✭✭
    baa wrote on June 12 2013, 8:35 PM: »

    Nice guide... we should add it to our little Wiki :-)

    ...and I spent hours and hours to get this DNSServer to work. :-D

    I'm pretty sure most users are extremely happy there's a built in dns-server ;-)

  • alias_rexalias_rex Posts: 531Members ✭✭

    Thanks for taking the time to type that all up. 

    I'm on OS X 10.6.8 Server and I'm stuck at Step 9. When I enter trailers.apple.com in Safari, the Apple Trailers page loads, so obviously something is amiss in my config. Does anything stand out in this screenshot?

    webserverplex.png

    sebseb wrote on June 12 2013, 6:31 PM: »

    9. If you open safari you can still use your all other web sites. If you enter trailers.apple.com you will get a no access message as there are nothing present in the folder you choose to use for keeping the files in.

    Our DNS and the website that's supposed to serve the ATV is working!

     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
  • sebsebsebseb Posts: 36Members ✭✭
    edited June 2013
    elstreif wrote on June 12 2013, 10:34 PM: »

    Thanks for taking the time to type that all up. 

    I'm on OS X 10.6.8 Server and I'm stuck at Step 9. When I enter trailers.apple.com in Safari, the Apple Trailers page loads, so obviously something is amiss in my config. Does anything stand out in this screenshot?

    webserverplex.png

    From the options that are the same in 10.7 it looks right.

    Are trailers.apple.com added to your servers DNS-service?

    Does the computer you're trying to acces/test trailers.apple.com from use your servers DNS-service?

    If you have the right config and dns is set up. Try to flush the DNS cache from the server and the machine you're using to test it from if it isn't the same machine as your server.

    In terminal you use the command: 

    sudo dscacheutil -flushcache (OS X <=10.6) or

    sudo killall -HUP mDNSResponder (OS X >=10.7)

  • laurentcolelaurentcole Posts: 11Members, Plex Pass Plex Pass

    GREAT job, it works perfectly on 10.8.4 and Server 2.2.1. Thx very much.

  • sebsebsebseb Posts: 36Members ✭✭
    laurentcole wrote on June 13 2013, 1:56 PM: »

    GREAT job, it works perfectly on 10.8.4 and Server 2.2.1. Thx very much.

    Perfect =)

    Can you confirm if this /Library/Server/Web/Config/apache2/sites/ is the path to the config files in 10.8? 

  • alias_rexalias_rex Posts: 531Members ✭✭
    edited June 2013

    The Mac Mini running 10.6.8 server is the same computer that I want to use as the PlexConnect server. It's also running Plex Media Server. If I open Safari on the Mini, it loads the trailers site normally. Flushing the DNS cache didn't make a difference. I don't use the DNS server on the Mini for anything other than resolving the Mini's name on the local network and so that OS X's VPN server and Time Machine server work. My router uses my ISPs DNS addresses.

    Here are a couple more screenshots.

    plexdns1.png

    dns1.png

    sebseb wrote on June 13 2013, 9:07 AM: »

    From the options that are the same in 10.7 it looks right.

    Are trailers.apple.com added to your servers DNS-service?

    Does the computer you're trying to acces/test trailers.apple.com from use your servers DNS-service?

    If you have the right config and dns is set up. Try to flush the DNS cache from the server and the machine you're using to test it from if it isn't the same machine as your server.

    In terminal you use the command: 

    sudo dscacheutil -flushcache (OS X <=10.6) or

    sudo killall -HUP mDNSResponder (OS X >=10.7)

     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
  • alias_rexalias_rex Posts: 531Members ✭✭
    edited June 2013

    The named.log has the following errors listed:

    13-Jun-2013 09:45:33.377 zone trailers.apple.com/IN/com.apple.ServerAdmin.DNS.public: has no NS records

    13-Jun-2013 09:45:33.377 zone trailers.apple.com/IN/com.apple.ServerAdmin.DNS.public: not loaded due to errors.

    13-Jun-2013 09:45:33.377 calling free_rbtdb(trailers.apple.com)

    13-Jun-2013 09:45:33.377 done free_rbtdb(trailers.apple.com)

     

    13-Jun-2013 09:51:41.590 zone trailers.apple.com/IN/com.apple.ServerAdmin.DNS.public: has no NS records

    13-Jun-2013 09:51:41.590 zone trailers.apple.com/IN/com.apple.ServerAdmin.DNS.public: not loaded due to errors.

    13-Jun-2013 09:51:41.590 thawing zone 'trailers.apple.com/IN' com.apple.ServerAdmin.DNS.public: bad zone

    13-Jun-2013 09:51:41.590 thawing all zones: bad zone

     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
  • alias_rexalias_rex Posts: 531Members ✭✭
    edited June 2013

    To anyone has got this working with OS X Server, can you post the results of the following Terminal command: nslookup trailers.apple.com

    When I enter that command, it shows that trailers.apple.com is forwarded to my router's DNS (192.168.2.1) instead of OS X Server's DNS (192.168.2.100).

    Server: 192.168.2.1

    Address: 192.168.2.1#53

     
    Non-authoritative answer:
    trailers.apple.com canonical name = trailers.apple.com.edgesuite.net.
    trailers.apple.com.edgesuite.net canonical name = a772.w11.akamai.net.
    Name: a772.w11.akamai.net
    Address: 23.59.188.72
    Name: a772.w11.akamai.net
    Address: 23.59.188.65
     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
  • sebsebsebseb Posts: 36Members ✭✭
    edited June 2013
    elstreif wrote on June 13 2013, 4:00 PM: »

    The Mac Mini running 10.6.8 server is the same computer that I want to use as the PlexConnect server. It's also running Plex Media Server. If I open Safari on the Mini, it loads the trailers site normally. Flushing the DNS cache didn't make a difference. I don't use the DNS server on the Mini for anything other than resolving the Mini's name on the local network and so that OS X's VPN server and Time Machine server work. My router uses my ISPs DNS addresses.

    Here are a couple more screenshots.

    [screenshots in post above]

    Think I found what's wrong with your DNS. The Nameserver hostname (in the blue box below) shouldn't start with mini.

    change it to just trailers.apple.com.

    plexdns1.png

    Hope this solves your problem =)

  • alias_rexalias_rex Posts: 531Members ✭✭
    edited June 2013

    Ha! That was it. Thank you so much. For some reason, I just didn't see that "mini" appended to the front.

    So, after I created the blank "0000_any_80_trailers.apple.com.conf" file and pasted in the three lines, Plex started working on the Apple TV 2, but only for a moment. I can get the Plex screen to load and sometimes play a video, but very quickly I get the "Accessing Trailers" or "Trailers Unavailable Please Try Later" messages. If I flush the DNS cache it works again--for about a minute--and then stops.

    conf.png

    How do I troubleshoot this?

     
    sebseb wrote on June 13 2013, 6:03 PM: »

    Think I found what's wrong with your DNS. The Nameserver hostname (in the blue box below) shouldn't start with mini.

    change it to just trailers.apple.com.

    attachicon.gifplexdns1.png

    Hope this solves your problem =)

     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
  • laurentcolelaurentcole Posts: 11Members, Plex Pass Plex Pass
    /Library/Server/Web/Config/apache2/sites/ is the correct path to the config files in 10.8
    I confirm that.
  • sebsebsebseb Posts: 36Members ✭✭
    edited June 2013
    elstreif wrote on June 13 2013, 6:47 PM: »

    Ha! That was it. Thank you so much. For some reason, I just didn't see that "mini" appended to the front.

    So, after I created the blank "0000_any_80_trailers.apple.com.conf" file and pasted in the three lines, Plex started working on the Apple TV 2, but only for a moment. I can get the Plex screen to load and sometimes play a video, but very quickly I get the "Accessing Trailers" or "Trailers Unavailable Please Try Later" messages. If I flush the DNS cache it works again--for about a minute--and then stops.

    conf.png

    How do I troubleshoot this?

    When I look at your screenshot from the site config of trailers.apple.com in the tab menu there's actually a tab named "proxy" maybe it's more reliable to do the settings there instead of in the config file?

    But how I don't know, have never used OS X Server 10.6 =/

    When it stops working on you ATV, does it still work if you enter the URL in your browser or is it broken there too?  

  • alias_rexalias_rex Posts: 531Members ✭✭
    edited June 2013
    Yeah, when it stops working on the Apple TV, I can then load the Apple Trailers page in Safari. I'm also getting error messages in PlexConnect even when the Apple TV isn't accessing PlexConnect.
     

    WebServer: serving .xml: /server-status?auto

    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:04:08] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /server-status?auto
    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:04:08] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /server-status?auto
    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:04:09] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /server-status?auto
    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:04:09] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /server-status?auto
    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:05:03] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /server-status?auto
    XMLConverter: HTTP response error: 400 Bad Request
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:05:04] "GET /server-status?auto HTTP/1.1" 200 -
    WebServer: serving .xml: /error/HTTP_SERVICE_UNAVAILABLE.html.var
    XMLConverter: HTTP response error: 404 Not Found
    XMLConverter: No Response from Plex Media Server
    192.168.2.100 - - [13/Jun/2013 17:08:09] "GET /error/HTTP_SERVICE_UNAVAILABLE.html.var HTTP/1.1" 200 -
     Mac mini 1.83 GHz (OS X Server 10.6.8)  Panasonic 32" LCD  SONY HT-CT150 Home Theater System 
«13456710
Sign In or Register to comment.