# \[PHP\] PlexAuth - Authentication for your domain using Plex

**URL:** <https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238>\
**Category:** Dev/API Corner\
**Tags:** other-dev\
**Created:** [June 7, 2016, 1:35am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238 "2016-06-07T01:35:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 1:35am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/1 "2016-06-07T01:35:42Z")

</div>

PlexAuth, PHP based Plex authentication for your domain.

> **[hjone72/PlexAuth](https://github.com/hjone72/PlexAuth)**
>
> Plex based authentication using PHP. Contribute to hjone72/PlexAuth development by creating an account on GitHub.

The idea was to secure my domain using familiar username and passwords for my users. I wanted to remove the need for users to have to sign in at each different website (comics, plex, requests, etc) but still wanted them to all be secure. I hate the idea of shared passwords so I came up with this project.

Using Nginx’s Auth\_Request module I’ve now been able to secure all the services using users Plex credentials.

 ![](https://raw.githubusercontent.com/hjone72/PlexAuth/master/screenshots/sign-in.JPG)

 ![](https://raw.githubusercontent.com/hjone72/PlexAuth/master/screenshots/signed-in.JPG)

Let me know what you guys think.

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 3:45am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/2 "2016-06-07T03:45:07Z")

</div>

Absolutely wow. Thank you so much for this. More motivation to get nginx working… because this is something i too want for my users.

I just have the hardest time with getting nginx to do anything, and i have grown to despise its lack of support. But i will try again to get it working for this.

So, i opted to try nginx with my synology. because it wont even load at all in ubuntu.

first step, install composer. which i was able to do… i think. i can ssh and get composer.phar to spit out errors.

second step, install rememberme from github. so, i set a folder path, /rememberme-master/ and navigated there. typed in cd /volume1/rememberme-master and then executed the command: composer require birke/rememberme but that fails, composer command not found. so not sure how to install that library.

i have the Plex Auth contents in my web folder directory, as /web/pa with the contents inside.

so, unable to figure out how to continue here, i googled things, but there is no documentation on how else to install a composer plugin really. the composer website is not clear on how to install a plugin, only how to make one.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 5:25am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/3 "2016-06-07T05:25:23Z")

</div>

I haven’t used composer on synology. My setup is running Ubuntu.

Does this help you out at all?  
[http://darktalker.com/2013/07/install-composer-synology/](http://darktalker.com/2013/07/install-composer-synology/)

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 5:41am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/4 "2016-06-07T05:41:38Z")

</div>

Yes, that’s the same URL i used to figure out how to install composer. I believe i have composer installed. i made sure my php settings had phar enabled. i then had logged into ssh as admin, and ran the command: curl -s [https://getcomposer.org/installer](https://getcomposer.org/installer) | php which dident give any errors.

my next step is installing rememberme. that’s what i’m stuck on.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 7:20am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/5 "2016-06-07T07:20:29Z")

</div>

Could you redownload from GitHub now please? I’ve added the rememberme in the inc folder…  
The only thing you should need to do is create a folder “tokens” and give nginx write permissions.

Let me know how you go.

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 7:51am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/6 "2016-06-07T07:51:58Z")

</div>

yes. i’ll do that then edit this post.

Downloaded newest version from github; created folder in /inc/ called tokens with full permissions.

loaded my page, and signed in with my plex account info (email address) and looks like it went through, to a nginx 405 not allowed.

issue? is that it denying my login?

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 8:32am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/7 "2016-06-07T08:32:45Z")

</div>

Could I see your nginx logs please?

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 9:12am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/8 "2016-06-07T09:12:28Z")

</div>

Sorry, took a while to get the right “log” for nginx. it was also full of other problems with everything else nginx wont run. so i purged the log of everything but the PlexAuth errors for today.

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 9:16am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/9 "2016-06-07T09:16:43Z")

</div>

I also have a ubuntu install of nginx, and i would like to try it there, but at least the synology version loads some of the pages i’ve tried. my ubuntu loads nothing at all that i have tried with it.

I have better results with apache, but your app is nginx dependent and i want to use it.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 9:16am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/10 "2016-06-07T09:16:55Z")

</div>

Could you please confirm that /volume1/web/pa/inc/config.ini.php exists and is readable by nginx?

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 9:29am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/11 "2016-06-07T09:29:02Z")

</div>

Yes, it should be. i edited the file name to remove the sample prefix, and footer file name. configured the config.ini with my info for plexpy.  
tested again after resetting the web engine. just shows 401 error.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 9:36am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/12 "2016-06-07T09:36:37Z")

</div>

The PlexPy section of the config is the least important. You MUST add the Plex server owners token in the file. See below for example:

```
[PLEX_SERVER]
token = "YOUR PLEX TOKEN"; //Follow this guide to get your token. https://support.plex.tv/hc/en-us/articles/204059436-Finding-your-account-token-X-Plex-Token
plexowner = "PLEX OWNERS USERNAME"; //Your Plex username. Not your email.

[PLEXPY]
plexpy = true; //Enable or disable PlexPy features. This is only if you are using my custom PlexPy fork.

[SERVER]
domain = "Your domain."; //This is used for the cookie.
session_path = "/var/lib/php5/sessions/sess_"; //This is your PHP session path folder with session prefix.

[REMEMBER_ME]
remember_cookie = "YTB-SID"; //Name of the cookie that will be used to remember user.
expire_time = "604800"; //Time for the cookie to expire (Seconds). 604800 = 1 week.

```

In the log you provided you are getting a lot of “Missing files”. See lines; 726, 727, 728

```
2016/06/07 01:19:02 [error] 30446#30446: *16160 FastCGI sent in stderr: "PHP message: PHP Warning: parse_ini_file(/volume1/web/pa/inc/config.ini.php): failed to open stream: No such file or directory in /volume1/web/pa/inc/include.php on line 4" while reading response header from upstream, client: 192.168.11.25, server: , request: "GET /pa/ HTTP/1.1", upstream: "fastcgi://unix:/run/php-fpm/php56-fpm.sock:", host: "192.168.11.26"
```

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 9:51am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/13 "2016-06-07T09:51:57Z")

</div>

The config.ini.php file is configured with the plex token from plexpy, as well as the default owner username, api key and correct IP address to my plexpy install.

i set all folder permissions to 755 for all of /pa/ and the include.php file is there.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 9:57am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/14 "2016-06-07T09:57:14Z")

</div>

Could you please post results of:

```
ls -la /volume1/web/pa/inc/config.ini.php
```

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 9:59am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/15 "2016-06-07T09:59:32Z")

</div>

-rwxrwxrwx 1 m1e1w1 users 792 Jun 7 02:26 /volume1/web/pa/inc/config.ini.php

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 7, 2016, 10:05am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/16 "2016-06-07T10:05:22Z")

</div>

sent you a PM

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 11:14am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/17 "2016-06-07T11:14:43Z")

</div>

I tried to copy the same file from nginx\_example to sites-available, and i get permission denied. as a regular user though. not logged into root user with the “Files” app.

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 7, 2016, 11:17am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/18 "2016-06-07T11:17:15Z")

</div>

Got the PlexAuth file made in sites-available folder now.

also, when i read off your example, the spelling of the folder name sites-available was miss spelled as sites-avaliable. that was the error there.

Will wait for the instructions to be published to continue with ubuntu install. Thanks again.

---

<div class="post-metadata">

**Author:** ![hjone72](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/hjone72/32/85715_2.png) [@hjone72](https://forums.plex.tv/u/hjone72)\
**Post date:** [June 8, 2016, 4:17am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/19 "2016-06-08T04:17:47Z")

</div>

Could you have a look at:

> **[hjone72/PlexAuth](https://github.com/hjone72/PlexAuth/tree/master/nginx_example)**
>
> PlexAuth - Plex based authentication using PHP

See if this helps you out.

---

<div class="post-metadata">

**Author:** ![m1e1w1](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/m1e1w1/32/2559_2.png) [@m1e1w1](https://forums.plex.tv/u/m1e1w1)\
**Post date:** [June 8, 2016, 5:00am UTC](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238/20 "2016-06-08T05:00:09Z")

</div>

looking that over now.

[Next page](https://forums.plex.tv/t/php-plexauth-authentication-for-your-domain-using-plex/147238.md?page=2)
