Giter Club home page Giter Club logo

Comments (2)

waiaryi avatar waiaryi commented on July 30, 2024 1

Another alternative that I think would be reasonable, not to have a folder in the project root that would only be used in development environments and not be omitting it in .gitignore, it would be to pass through an environment variable the value of the virtual host. In this way, the default configuration of the docker-compose.yml file is maintained.
In my case, I used the same APP_SERVER environment variable that Sail uses to refer to the virtual host, I passed it to the template of the NGINX configuration.

./.env

APP_SERVICE=anis.test

./docker-compose.yml

services:
    nginx:
        environment:
            - SSL_PORT=${SSL_PORT:-443}
            - APP_SERVICE=${APP_SERVICE:-laravel.test}
    anis.test:
        build:
            context: ./vendor/laravel/sail/runtimes/8.1
            dockerfile: Dockerfile
            args:
                WWWGROUP: '${WWWGROUP}'
        image: sail-8.1/app
        ....

nginx/templates/default.conf.template

server {
    listen  80  default_server;
    server_name localhost;

    return  301 https://$host:${SSL_PORT}$request_uri;
}

server {
    listen  443 ssl default_server;
    server_name localhost;

    # Self signed certificates
    # Don't use them in a production server!
    ssl_certificate     /etc/nginx/certs/server.pem;
    ssl_certificate_key /etc/nginx/certs/server.key;

    location / {
        proxy_pass	http://${APP_SERVICE};
    }
}

from sail-ssl.

ryoluo avatar ryoluo commented on July 30, 2024

You can publish Nginx configuration file by this command:

$ php artisan sail-ssl:publish

Then you can change server_name directive

nginx/templates/default.conf.template

server {
    listen  80  default_server;
    server_name laravel.test;

    return  301 https://$host:${SSL_PORT}$request_uri;
}

server {
    listen  443 ssl default_server;
    server_name laravel.test;

    # Self signed certificates
    # Don't use them in a production server!
    ssl_certificate     /etc/nginx/certs/server.pem;
    ssl_certificate_key /etc/nginx/certs/server.key;

    location / {
        proxy_pass	http://laravel.test;
    }
}

from sail-ssl.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.