[Support] Linuxserver.io - Nginx


Recommended Posts

On 2.2.2018 at 8:43 AM, ebnerjoh said:

Hello,

 

I have a special question regarding the dockers "nginx" and "letsencrypt".

 

Currently I have the following setup:

 

1) LetsEncrypt as ReverseProxy

2) Apps behind ReverseProxy, e.g. NextCloud and Apache

 

I noticed now that the Apache-Docker has a very outdated PHP Version (5.9) so I want to change this. I havent found a newer Apache Docker so the question is now:

 

A) Should I but my Webpages I have currently on Apache onto the LetsEncrpyt-Docker?

B) Or should I forward from the LetsEncrpyt-Docker to the NGINX-Docker (like I do now with Apache)?

 

And then another question: I need a simple site-conf-example for a Joomla Website for nginx. It only needs to listen on a special HTTPS Port, not on HTTP.

 

Br,

Johannes

 

Is no one out there who could answer my questions?

 

Br

Johannes

Link to comment
4 hours ago, ebnerjoh said:

 

Is no one out there who could answer my questions?

 

Br

Johannes

 

Apache vs nginx is totally up to you. We currently don't have plans of updating the apache container so you can try moving it over to nginx and see if it works. 

 

With regards to Joomla, not sure as I haven't tried it. But I do run wordpress and it works fine

Link to comment
1 hour ago, aptalca said:

 

Apache vs nginx is totally up to you. We currently don't have plans of updating the apache container so you can try moving it over to nginx and see if it works. 

 

With regards to Joomla, not sure as I haven't tried it. But I do run wordpress and it works fine

 

Hi, do you have an example sites.conf for NGINX for me?

 

Br,

Johannes

Link to comment
6 hours ago, aptalca said:

 

For wordpress? 

 

Also interested. I'm stuck right now trying to get a site to work that is running through cloudflare > nginx > apache-php (docker) > wordpress install. If I could just axe having to run apache docker that would be great. Does nginx have builtin php support? 

Link to comment
4 hours ago, neebski said:

 

Also interested. I'm stuck right now trying to get a site to work that is running through cloudflare > nginx > apache-php (docker) > wordpress install. If I could just axe having to run apache docker that would be great. Does nginx have builtin php support? 

 

Yes, it has php7. 

 

I'll post my config tomorrow

Link to comment

Ok, so I looked through my nginx config for wordpress. For a basic install, I literally just dropped the wordpress install files into the www folder created the database in a separate mariadb container, and browsed to the wp-admin/install.php to install. That was it. Initially, I didn't have to change anything in the nginx/wordpress site config.

 

For reverse proxy through a separate letsencrypt/nginx container, I added the following:

 

letsencrypt site config:

        location / {
                proxy_pass http://127.0.0.1:81/;
                proxy_read_timeout    90;
                proxy_connect_timeout 90;
                proxy_redirect        off;

                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 https;
                proxy_set_header      X-Forwarded-Port 443;
                proxy_set_header      Host $host;
        }

and add the following to wordpress wp-config.php:

if ( (!empty( $_SERVER['HTTP_X_FORWARDED_HOST'])) ||
     (!empty( $_SERVER['HTTP_X_FORWARDED_FOR'])) ) {
    $_SERVER['HTTPS'] = 'on';
}

 

In the first one, change the http://127.0.0.1:81/ to your unraid ip and nginx/wordpress http port.

 

The second one makes sure that wordpress serves https over the http port.

 

Then in the wordpress gui (accessing locally through the unraid ip and nginx port) login to the admin interface, go to settings and change the server address to your custom domain address so wordpress redirects all requests to that external address.

 

That was it

 

For pretty permalinks, I had to add this to the nginx/wordpress container's site-config:

        if (!-e $request_filename) {
                rewrite ^.*$ /index.php last;
        }

Later on, you may want to change some settings in the php.ini for certain . Currently there is no easy way, but we have a PR in process that will make it super easy. It should be merged within a week or two.

Edited by aptalca
Link to comment
  • 2 weeks later...
  • 2 months later...

Could someone share a complete nginx conf file for me PLEASE

 

I was happy with Apache docker but it stopped working and wont be fixed so I have to move to nginx. 

 

I reverse proxy etc all my dockers so as busy a config as poss please

 

Deluge, Sabnzbd, Sonarr, Radarr, Mylar, Headphones, LazyLibrarian, Ubooquity, Jackett, NZBhydra

 

All sat behind my webserver in the good old Apache days ?

Link to comment
7 hours ago, methanoid said:

Could someone share a complete nginx conf file for me PLEASE

 

I was happy with Apache docker but it stopped working and wont be fixed so I have to move to nginx. 

 

I reverse proxy etc all my dockers so as busy a config as poss please

 

Deluge, Sabnzbd, Sonarr, Radarr, Mylar, Headphones, LazyLibrarian, Ubooquity, Jackett, NZBhydra

 

All sat behind my webserver in the good old Apache days ?

 

If you do RP, you should use our letsencrypt container. Check the Readme to enable RP for some of the applications in your list. 

Edited by saarg
Link to comment
22 hours ago, saarg said:

 

If you do RP, you should use our letsencrypt container. Check the Readme to enable RP for some of the applications in your list. 

 

Went to the LetsEncrypt support thread to read someone saying "Dont use this if all you need is to use Nginx"... which is probably all I need... Dont think I need certs. Just access to see an example FULL conf where someone has used RP.... ?

Link to comment
1 hour ago, methanoid said:

 

Went to the LetsEncrypt support thread to read someone saying "Dont use this if all you need is to use Nginx"... which is probably all I need... Dont think I need certs. Just access to see an example FULL conf where someone has used RP.... ?

 

This nginx image is meant to be mainly a webserver, whereas the letsencrypt one is meant for reverse proxy. It doesn't mean that you can't use nginx for reverse proxy, it's just that the default site config of the letsencrypt image has some bits that makes reverse proxy much easier. 

 

For instance the letsencrypt image has a file called proxy.conf https://github.com/linuxserver/docker-letsencrypt/blob/master/root/defaults/proxy.conf

Feel free to drop that into the nginx folder in this container and include it in the site config for proxies. 

 

Also, the letsencrypt container has a folder full of preset reverse proxy configs here: https://github.com/linuxserver/docker-letsencrypt/blob/master/root/defaults/proxy.conf

 

Also check out the two reverse proxy examples in the letsencrypt default site config: https://github.com/linuxserver/docker-letsencrypt/blob/master/root/defaults/default

 

This should set you on the right path

Link to comment
  • 2 months later...

@aptalca  I had this working months ago and then silly sod I moved back to bare Windows.. Now back to unRAID and I cannot make it work with my previous config files...

 

I have "default" which I believe belongs in appdata/nginx/nginx/site-confs/

I have "proxy-control.conf" which I am guessing goes next to nginx.conf in appdate/nginx/nginx/

 

But no dice.. and I cannot even STOP the docker....

 

Some help would be great, please?! 

Link to comment
6 hours ago, methanoid said:

@aptalca  I had this working months ago and then silly sod I moved back to bare Windows.. Now back to unRAID and I cannot make it work with my previous config files...

 

I have "default" which I believe belongs in appdata/nginx/nginx/site-confs/

I have "proxy-control.conf" which I am guessing goes next to nginx.conf in appdate/nginx/nginx/

 

But no dice.. and I cannot even STOP the docker....

 

Some help would be great, please?! 

 

Default goes in that location. Proxy-control is not one of the default ones and must have been user generated. The location should be referenced in the default site config. 

 

Post your log along with the default site config and we'll take a look

  • Like 1
Link to comment
40 minutes ago, methanoid said:

Default attached. Log is zero bytes... ?

 

But if I look at log via unRAID web interface its full of

 

nginx: [emerg] "location" directive is not allowed here in /config/nginx/site-confs/default:53


 

 

 

default

 

You have an extra "}" right above the sab location. Delete that and restart

  • Like 1
Link to comment
  • 1 month later...

This is a bit of an odd one so forgive me and i know it may sound totally mad

 

For years i've hosted various servers and websites on an unraid server. Its my job so i host test sites and everything else when i'm working remotely

 

I have a custom reverse proxy coded and working in nginx and a number of nginx backend server. This allows me to route different websites to different instances of nginx entirely. Sometimes i get stuck with older websites or those that have bugs with certain php versions and i need to change it

 

Right now the nginx docker ships with php 7.1.17 which is great. My question is, is there any way to change the php version without manually removing and installing a new one each load?

 

I was thinking perhaps a set of stable php versions all installed at the same time but with fast-cgi on different ports. You could then change the fast-cgi port used by nginx and therefore change the php version used

 

The most commonly selectable options i've seen are:

  • 4.4
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 5.6
  • 7.0
  • 7.1
  • 7.2

My idea is to use dockers instead of something like MultiPHP so everything was truely isolated. I know the idea behind it is mad and likely not usable by many but its worth a shot :)

Link to comment
13 minutes ago, bigjme said:

This is a bit of an odd one so forgive me and i know it may sound totally mad

 

For years i've hosted various servers and websites on an unraid server. Its my job so i host test sites and everything else when i'm working remotely

 

I have a custom reverse proxy coded and working in nginx and a number of nginx backend server. This allows me to route different websites to different instances of nginx entirely. Sometimes i get stuck with older websites or those that have bugs with certain php versions and i need to change it

 

Right now the nginx docker ships with php 7.1.17 which is great. My question is, is there any way to change the php version without manually removing and installing a new one each load?

 

I was thinking perhaps a set of stable php versions all installed at the same time but with fast-cgi on different ports. You could then change the fast-cgi port used by nginx and therefore change the php version used

 

The most commonly selectable options i've seen are:

  • 4.4
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 5.6
  • 7.0
  • 7.1
  • 7.2

My idea is to use dockers instead of something like MultiPHP so everything was truely isolated. I know the idea behind it is mad and likely not usable by many but its worth a shot :)

I'm almost sure we are not going to make a container like that. We install the php packages from the alpine repo, and there aren't all the versions you want. This also feels like it might be only a very few people that would need it. 

Link to comment
4 hours ago, bigjme said:

This is a bit of an odd one so forgive me and i know it may sound totally mad

 

For years i've hosted various servers and websites on an unraid server. Its my job so i host test sites and everything else when i'm working remotely

 

I have a custom reverse proxy coded and working in nginx and a number of nginx backend server. This allows me to route different websites to different instances of nginx entirely. Sometimes i get stuck with older websites or those that have bugs with certain php versions and i need to change it

 

Right now the nginx docker ships with php 7.1.17 which is great. My question is, is there any way to change the php version without manually removing and installing a new one each load?

 

I was thinking perhaps a set of stable php versions all installed at the same time but with fast-cgi on different ports. You could then change the fast-cgi port used by nginx and therefore change the php version used

 

The most commonly selectable options i've seen are:

  • 4.4
  • 5.1
  • 5.2
  • 5.3
  • 5.4
  • 5.5
  • 5.6
  • 7.0
  • 7.1
  • 7.2

My idea is to use dockers instead of something like MultiPHP so everything was truely isolated. I know the idea behind it is mad and likely not usable by many but its worth a shot :)

You can always pull the official php images (whichever version you need) and point the nginx fcgi parameter to the php container's ip address

Link to comment
13 hours ago, aptalca said:

You can always pull the official php images (whichever version you need) and point the nginx fcgi parameter to the php container's ip address

OK I did not think of this at all.... Safe to say this would be a much easier approach than what I was thinking of as it's more scalable

 

Looks like I'm going to need to learn some docker potentially! 

 

Thanks both for your replies. As I say, it was a bit of an odd one and one I didn't really expect a response from :)

Link to comment
  • 3 weeks later...
On 9/14/2018 at 12:30 AM, aptalca said:

You can always pull the official php images (whichever version you need) and point the nginx fcgi parameter to the php container's ip address 

Would you say this approach is production ready?

 

I am using your docker for a number of self hosted enterprise apps and they are not fully 7.2 ready yet.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.