Setup Laravel as API location block on Nginx gives a 404

Have the tides ever turned twice on any open problem?

Knife as defense against stray dogs

What kind of footwear is suitable for walking in micro gravity environment?

PTIJ: Which Dr. Seuss books should one obtain?

Animating wave motion in water

What is the tangent at a sharp point on a curve?

Justification failure in beamer enumerate list

Can other pieces capture a threatening piece and prevent a checkmate?

Should I be concerned about student access to a test bank?

Why doesn't the chatan sign the ketubah?

Print last inputted byte

Exit shell with shortcut (not typing exit) that closes session properly

Determine voltage drop over 10G resistors with cheap multimeter

Help with identifying unique aircraft over NE Pennsylvania

Is there any common country to visit for uk and schengen visa?

When should a starting writer get his own webpage?

Friend wants my recommendation but I don't want to

Why doesn't the fusion process of the sun speed up?

Fair way to split coins

How can a new country break out from a developed country without war?

Would this string work as string?

pipe commands inside find -exec?

What (if any) is the reason to buy in small local stores?

Was World War I a war of liberals against authoritarians?



Setup Laravel as API location block on Nginx gives a 404














0















I'm trying to setup a website with React as my front-end and Laravel as my back-end. My server is an AWS instance setup with using Nginx on Ubuntu.



Currently I have Laravel in /var/www/laravel and my React code in /var/www/html. When I access the site http://www.website.com I can see my react placeholder, but when I try to access Laravel http://www.website.com./api I get a 404.



I have set all the permissions in Laravel correctly and all the all the php loads like it should. I can get Laravel working if I set everything in my default file to have Laravel be root.



Here's what my default file looks like:



server {

listen 80 default_server;
listen [::]:80 default_server;

index index.html index.htm index.php;

server_name _;

location /api {
root /var/www/laravel/public;
try_files $uri $uri/ @laravel;
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
}

location @laravel {
rewrite /api/(.*)$ /index.php?/$1 last;
}

location / {
root /var/www/html;
try_files $uri $uri/ =404;
}

location ~ /.(?!well-known).* {
deny all;
}
}


I'm trying to learn Nginx and Laravel so the above is somethings I pieced together after some Googlefoo.









share







New contributor




Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I'm trying to setup a website with React as my front-end and Laravel as my back-end. My server is an AWS instance setup with using Nginx on Ubuntu.



    Currently I have Laravel in /var/www/laravel and my React code in /var/www/html. When I access the site http://www.website.com I can see my react placeholder, but when I try to access Laravel http://www.website.com./api I get a 404.



    I have set all the permissions in Laravel correctly and all the all the php loads like it should. I can get Laravel working if I set everything in my default file to have Laravel be root.



    Here's what my default file looks like:



    server {

    listen 80 default_server;
    listen [::]:80 default_server;

    index index.html index.htm index.php;

    server_name _;

    location /api {
    root /var/www/laravel/public;
    try_files $uri $uri/ @laravel;
    location ~ .php$ {
    fastcgi_split_path_info ^(.+.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    }
    }

    location @laravel {
    rewrite /api/(.*)$ /index.php?/$1 last;
    }

    location / {
    root /var/www/html;
    try_files $uri $uri/ =404;
    }

    location ~ /.(?!well-known).* {
    deny all;
    }
    }


    I'm trying to learn Nginx and Laravel so the above is somethings I pieced together after some Googlefoo.









    share







    New contributor




    Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I'm trying to setup a website with React as my front-end and Laravel as my back-end. My server is an AWS instance setup with using Nginx on Ubuntu.



      Currently I have Laravel in /var/www/laravel and my React code in /var/www/html. When I access the site http://www.website.com I can see my react placeholder, but when I try to access Laravel http://www.website.com./api I get a 404.



      I have set all the permissions in Laravel correctly and all the all the php loads like it should. I can get Laravel working if I set everything in my default file to have Laravel be root.



      Here's what my default file looks like:



      server {

      listen 80 default_server;
      listen [::]:80 default_server;

      index index.html index.htm index.php;

      server_name _;

      location /api {
      root /var/www/laravel/public;
      try_files $uri $uri/ @laravel;
      location ~ .php$ {
      fastcgi_split_path_info ^(.+.php)(/.+)$;
      fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
      }
      }

      location @laravel {
      rewrite /api/(.*)$ /index.php?/$1 last;
      }

      location / {
      root /var/www/html;
      try_files $uri $uri/ =404;
      }

      location ~ /.(?!well-known).* {
      deny all;
      }
      }


      I'm trying to learn Nginx and Laravel so the above is somethings I pieced together after some Googlefoo.









      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I'm trying to setup a website with React as my front-end and Laravel as my back-end. My server is an AWS instance setup with using Nginx on Ubuntu.



      Currently I have Laravel in /var/www/laravel and my React code in /var/www/html. When I access the site http://www.website.com I can see my react placeholder, but when I try to access Laravel http://www.website.com./api I get a 404.



      I have set all the permissions in Laravel correctly and all the all the php loads like it should. I can get Laravel working if I set everything in my default file to have Laravel be root.



      Here's what my default file looks like:



      server {

      listen 80 default_server;
      listen [::]:80 default_server;

      index index.html index.htm index.php;

      server_name _;

      location /api {
      root /var/www/laravel/public;
      try_files $uri $uri/ @laravel;
      location ~ .php$ {
      fastcgi_split_path_info ^(.+.php)(/.+)$;
      fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
      }
      }

      location @laravel {
      rewrite /api/(.*)$ /index.php?/$1 last;
      }

      location / {
      root /var/www/html;
      try_files $uri $uri/ =404;
      }

      location ~ /.(?!well-known).* {
      deny all;
      }
      }


      I'm trying to learn Nginx and Laravel so the above is somethings I pieced together after some Googlefoo.







      ubuntu nginx amazon-web-services





      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 min ago









      MikeMike

      101




      101




      New contributor




      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Mike is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });






          Mike is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958888%2fsetup-laravel-as-api-location-block-on-nginx-gives-a-404%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          Mike is a new contributor. Be nice, and check out our Code of Conduct.










          draft saved

          draft discarded


















          Mike is a new contributor. Be nice, and check out our Code of Conduct.













          Mike is a new contributor. Be nice, and check out our Code of Conduct.












          Mike is a new contributor. Be nice, and check out our Code of Conduct.
















          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f958888%2fsetup-laravel-as-api-location-block-on-nginx-gives-a-404%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Список ссавців Італії Природоохоронні статуси | Список |...

          Українські прізвища Зміст Історичні відомості |...