jjmaster's avatar

Issue deploying my APP into production in a VPS

Hello:

I am developing an APP with the stack:

  • VUE
  • Intertia
  • Laravel

I have configured every part of the APP with Docker containers:

  • NGINX
  • PHP
  • MySQL
  • Artisan
  • Composer
  • NPM

All with the help of this tutorial: https://laracasts.com/series/the-docker-tutorial

I got the APP working in local. I have set up a VM with Debian and the APP is working in localhost.

Now is the moment of taking the APP into production and I have a VPS server that I control through SSH and Plesk.

I have configured the NGINX container to expose port 8444 and redirect it to 443 internally. I have configured all requests to port 443 for the domain, to be forwarded to por 8444 (through Plesk).

I can see that all the resquest are being accepted from NGINX with the comand:

docker logs nginx

But visually, in the web browser, I am getting the error: 400 Bad Request The plain HTTP request was sent to HTTPS port nginx/1.25.2

This is the configuration that I have for NGINX:

server {
        listen 80;
        listen [::]:80;

        index index.php index.html;
        root /var/www/html/public;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
         server_name [subdomain].[domain].com;
}

server{
        listen 443 ssl;
        index index.php index.html;
        root /var/www/html/public;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;

        ssl_certificate /etc/nginx/ssl/fullchain5.pem;
        ssl_certificate_key /etc/nginx/ssl/privkey5.pem;

        server_name [subdomain].[domain].com;

        location / {
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass php:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                proxy_pass http://0.0.0.0:8444;
                proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
                proxy_set_header Host              $host;
                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 $scheme;
                proxy_redirect off;
                proxy_read_timeout 5m;
    }
}

I have heard that I might need to create a new TRAEFIK container, but I am not really sure if that's the path be to taken. It might just be a little configuration that I have to tweak.

Thanks a lot for your time.

My best regards.

0 likes
0 replies

Please or to participate in this conversation.