0

I am trying to get my docker compose project to work in azure.

Locally it works as expected, but in azure the /api location get routes return a 404 not found error from the regular theme, and post routes return a 405 error.

I don't have a lot of experience with nginx, but the problem might be the subdomain of my-software.azurewebsites.net...

upstream vue {
  server vue:3000/;
}

upstream laravel {
  server laravel:9000/;
}

server {
  listen 80;
  listen  [::]:80;
  index index.php index.html;
  error_log  /var/log/nginx/error.log;
  access_log /var/log/nginx/access.log;
  root /var/www/public;

  location / {
    root /app;
    proxy_pass https://vue;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-Host localhost;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;
  }

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

  # Nginx Pass requests to PHP-FPM
  location ~ \.php$ {
    #try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass laravel;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_path_info;
  }
}

I've tried to add trailing slashes to the locations and upstreams, but this made no difference. I've tried to change the forwarded host from localhost to my-project.azurewebsites.net but this also didn't worked. Any ideas about what the problem might be?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120

0 Answers0