S
S
Sergey Burduzha2020-01-10 14:38:39
css
Sergey Burduzha, 2020-01-10 14:38:39

How to run 2 sites locally in nginx?

I work in ubuntu, installed laradock as a local server.
When I created the first site, an error occurred, which I looked through the terminal
dockde-compose logs nginx
. It turned out that there are two files in the laradock/nginx/sites folder that refer to the same port 80.
I deleted the default file and continued working on the site.
Now I had to add a new site and again the same error.
What should I do, change the port? If so, which one?

server {

    listen 80 default_server;
    listen [::]:80 default_server ipv6only=on;

    # For https
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server ipv6only=on;
    # ssl_certificate /etc/nginx/ssl/default.crt;
    # ssl_certificate_key /etc/nginx/ssl/default.key;

    server_name tlaravel.loc;
    root /var/www/tlaravel.loc/public;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eduardich, 2019-03-21
@ItWorld

It's called mobile first. That is, all CSS is initially written for mobile / tablets, which implies the use of the site mainly on phones. And then CSS media queries are adjusted to fit larger screens.
If media (min-width: ) - then mobile first,
If media (max-width: ) - then vice versa

V
Vadim, 2020-01-12
@Viji

Hello,
you need to remove default_server from here everywhere, let it listen on the same port. Make another same config file, write another server name there instead of server_name tlaravel.loc for example vasya.ru
make sure that nginx sees it, write the path to the files of this server, make sure that vasya.ru refers to the same IP address as tlaravel. loc and you will be happy... if you have everything in a container, then you need to load your site through the Dockerfile into the same container

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question