Skip to content

Conversation

@qiqizjl
Copy link
Contributor

@qiqizjl qiqizjl commented Jun 24, 2017

Demo

version: '2'
services:
  nginx-proxy:
    image: qiqizjl/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "81:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro

  php-fpm:
    image: php:fpm-alpine
    environment:
      - VIRTUAL_HOST=php-fpm.local
      - VIRTUAL_ROOT=/var/www/html
      - VIRTUAL_PORT=9000
      - VIRTUAL_PROTO=fastcgi

@rakshazi
Copy link

rakshazi commented Jul 5, 2017

@jwilder can you merge it into master, please? It's really cool feature

@AndreaGiardini
Copy link

Fantastic! I have exactly this problem ! :)

@jwilder can you please have a look? Thanks!

@AndreaGiardini
Copy link

@qiqizjl Could you please squash the commits to one ?

Moreover, in my case I do not have any fastcgi.conf but only fastcgi_params, so this pull request does not work for me.

@egyptianbman
Copy link

I just wanted to comment on the squashing, you can enable squash commit merge in github. https://github.com/blog/2141-squash-your-commits

@kamermans
Copy link
Contributor

Looks like a cool feature - I won't need 23 extra copies of nginx running on my microsite-host anymore 👍

@GuerrillaCoder
Copy link

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Oct 19, 2017

@GuerrillaCoder I think this is not a public function, you can separate a separate branch to do this thing alone

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Oct 19, 2017

@jwilder Can you look at this PullRequest. Is it possible to merge?

@GuerrillaCoder
Copy link

I cant get this to work. I downloaded this file: https://github.com/qiqizjl/nginx-proxy/blob/2eb2ae9c93c46ebb7031a2a71beef2bf18da89b7/nginx.tmpl

Then run this compose file:

version: "3.3"

services:
  main-webserver:
    image: jwilder/nginx-proxy
    ports:
    - 80:80
    - 443:443
    volumes:
    - main-webserver-html:/usr/share/nginx/html
    - main-webserver-logs:/var/log/nginx
    - main-webserver-conf:/etc/nginx
    - main-webserver-vhosts:/etc/nginx/conf.d
    - main-webserver-certs:/etc/nginx/certs
    - main-webserver-htpasswd:/etc/nginx/htpasswd
    - /d/docker/nginx.tmpl:/app/nginx.tmpl
    - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: always
    networks:
      main-web:

  wordpress-fpm:
    image: wordpress:php7.1-fpm
    environment:
      - VIRTUAL_HOST=wordpress-fpm.local
      - VIRTUAL_ROOT=/var/www/html
      - VIRTUAL_PORT=9000
      - VIRTUAL_PROTO=fastcgi
    restart: always
    ports:
      - 9000
    networks:
      main-web:

volumes:
  main-webserver-html:
  main-webserver-logs:
  main-webserver-conf:
  main-webserver-vhosts:
  main-webserver-certs:
  main-webserver-htpasswd:
  
networks:
  main-web:

I then add hosts file entry for wordpress-fpm.local in hosts to my docker-machine ip (192.168.99.100) and it doesn't work.

The server block is output like this:

# wordpress-fpm.local
upstream wordpress-fpm.local {
                                ## Can be connect with "docker_main-web" network
                        # docker_wordpress-fpm_1
                        server 172.18.0.2:9000;
}
server {
        server_name wordpress-fpm.local;
        listen 80 ;
        access_log /var/log/nginx/access.log vhost;
        location / {
                root   /var/www/html;
                include fastcgi.conf;
                fastcgi_pass wordpress-fpm.local;
        }
}

Any idea what I did wrong?

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Oct 19, 2017

@GuerrillaCoder I think there is no problem, what is wrong with it?

@GuerrillaCoder
Copy link

GuerrillaCoder commented Oct 19, 2017

@qiqizjl looks like my bad, /var/www/html is pointing to files inside nginx-proxy container and not the wordpress container. I guess I need to map a subfolder as a volume .

I can't see good way of doing that. any suggestions?

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Oct 19, 2017

@GuerrillaCoder /var/www/html refers to the root directory of the PHP project in the container in the wordpress. You can try to run nginx -t in a nginx-proxy container to see if there is an error.

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Oct 19, 2017

@GuerrillaCoder I look at the wordpress php-fpm image. Found that he put the wordpress file under /usr/src/wordpress. Then it should be
-VIRTUAL_ROOT = /usr/src/wordpress

Copy link
Collaborator

@jwilder jwilder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @qiqizjl!

@jwilder jwilder merged commit fc36514 into nginx-proxy:master Oct 20, 2017
@xgenvn
Copy link

xgenvn commented Dec 13, 2017

  include fastcgi.conf;

fastcgi.conf missing from the configuration will make the nginx-web container hang.

I have a dumb question, that where should I reference this file?
Will it be referenced directly from VIRTUAL_ROOT or do I have to add it when start the nginx-proxy container?

@saesh saesh mentioned this pull request Dec 14, 2017
@saesh
Copy link

saesh commented Dec 14, 2017

@xgenvn As mentioned in #983 the fastcgi.conf is already present, what is not present is the configuration of the index file which should be done by yourself since it is a custom setting.

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Dec 14, 2017

@xgenvn Sorry, I'm late. Fastcgi.conf should be nginx comes with the configuration file. If you find an error, you can provide the next nginx version and the Docker image name

@xgenvn
Copy link

xgenvn commented Dec 14, 2017

I found the image this repo using the template from current repo, and using nginx without the tag, fastcgi config comes with the name "fastcgi_params". So that's the problem, similar version though (1.13.7). I'll find a way to work around.

Thanks.

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Dec 14, 2017

@xgenvn I found the answer to the question. I looked under the nginx image. Found in the nginx: latest image and does not include the fastcgi.conf. But it is included in nginx: alpine. I will try to fix it as soon as possible. Thank you very much

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Dec 14, 2017

@xgenvn I think you could try modifying nginx first to nginx: apline. To see if the problem has been solved

@xgenvn
Copy link

xgenvn commented Dec 14, 2017

@qiqizjl yes, I think that's simpler than replacing the name from nginx.tmpl.
Thank you.

@HalisCz HalisCz mentioned this pull request Mar 19, 2018
@setiseta
Copy link

This seems only be available in the :alpine tagged version. not in the default / latest

@eigood
Copy link

eigood commented Mar 29, 2018

How does this work for a shared system-wide nginx? I have many sub-projects that come and go, and they have their own volumes, their own files. The generated default.conf specifies root /var/www/html;, and php files are being forwarded to the wordpress container(s), but then nothing is capable of serving out the static files.

@xgenvn
Copy link

xgenvn commented Mar 30, 2018

@eigood you can put those static sites on your custom conf? However, I think you can also serve the static files under a container (that runs nginx), so you'll have nginx -> nginx -> static files. Btw, I think your question is not quite related to this issue.

@marlosirapuan
Copy link

I got a error when use fastgci. When I access site.com/index.php

"GET /wp-admin/css/install.min.css" 403
[01-Jun-2018 21:29:59] WARNING: [pool www] child 69 said into stderr: "NOTICE: Access to the script '/usr/src/wordpress/wp-admin/css/install.min.css' has been denied (see security.limit_extensions)"

[01-Jun-2018 21:29:59] WARNING: [pool www] child 69 said into stderr: "NOTICE: Access to the script '/usr/src/wordpress/wp-admin/js/language-chooser.min.js' has been denied (see security.limit_extensions)"

And this screen:
screen shot 2018-06-01 at 18 35 33

I've already changed the folder to /var/www/html as well.. but not works js and css files. : (

@qiqizjl
Copy link
Contributor Author

qiqizjl commented Jun 2, 2018

@marlosirapuan Hello, fastcgi can only handle php files and cannot handle static resources. If you have static resource requirements, you need other nginx containers, that is, nginx-proxy->nginx->staticfile.

@marlosirapuan
Copy link

@qiqizjl humm..i’ll try! Thank you. 👊🏻

@rcauquil
Copy link

@marlosirapuan any luck with this ? I have the same issue and I'm not an nginx guy expert...

@bkraul
Copy link

bkraul commented Jul 1, 2018

@qiqizjl Can you elaborate? Are you saying that nginx-proxy cannot handle this through configuration?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.