Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reference nginx hostname from php-fpm #1119

Closed
feribg opened this issue Sep 1, 2017 · 2 comments
Closed

Reference nginx hostname from php-fpm #1119

feribg opened this issue Sep 1, 2017 · 2 comments
Labels

Comments

@feribg
Copy link

feribg commented Sep 1, 2017

Info:

  • Docker version (all):
  • Laradock commit (all):
  • System info (Mac, PC, Linux): all
  • System info disto/version:

Issue:

Nginx container depends on php-fpm which doesnt allow to use a custom hostname and reference it within PHP.


Expected behavior:

Should be able to call <?php some_func_get_url('laradock.local.nginx.host') ?>

Reproduce:


Relevant Code:

Possible solution that works fine is to make an alias as described below with the new hostname as the nginx host, then add both php-fpm and nginx on the new network, avoiding circular container dependencies.
https://medium.com/@yani/two-way-link-with-docker-compose-8e774887be41

    nginx:
      build:
        context: ./nginx
        args:
          - PHP_UPSTREAM=php-fpm
      volumes_from:
          - applications
      volumes:
          - ${NGINX_HOST_LOG_PATH}:/var/log/nginx
          - ${NGINX_SITES_PATH}:/etc/nginx/sites-available
      ports:
          - "${NGINX_HOST_HTTP_PORT}:80"
          - "${NGINX_HOST_HTTPS_PORT}:443"
      extra_hosts:
          - "your.nginx.local.hostname:127.0.0.1"    
      depends_on:
          - php-fpm
      networks:
        main:
          aliases:
            - "${NGINX_HOSTNAME}"
@stale
Copy link

stale bot commented Feb 2, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Feb 2, 2020
@stale
Copy link

stale bot commented Feb 23, 2020

Hi again 👋 we would like to inform you that this issue has been automatically closed 🔒 because it had not recent activity during the stale period. We really really appreciate your contributions, and looking forward for more in the future 🎈.

@stale stale bot closed this as completed Feb 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant