ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Nginx Config Need to Point Folder Reference Without Stripping

    IT Discussion
    nginx web server
    2
    8
    798
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      scottalanmiller
      last edited by

      Now I'm sure that I'm a fool for not using Caddy which uses special mind probes to sense what my software will need and configure itself automatically, but let's just assume that I'm going to stick with Nginx. Here is what I am trying to figure out...

      In my server block I have a "location / {}" already which is working fine.

      Now I need a "location /api {}" block that goes to a ReactJS application that needs to think that it is processing the /api route. But for obvious reasons, this is stripped and there is no physical /api to point to. So I'm not sure how this would work.

      1 Reply Last reply Reply Quote 0
      • S
        stacksofplates
        last edited by

        I'm missing the obvious reasons. Why is there no where for /api to actually go?

        S 1 Reply Last reply Reply Quote 0
        • S
          scottalanmiller @stacksofplates
          last edited by

          @stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:

          I'm missing the obvious reasons. Why is there no where for /api to actually go?

          Because, in this particular case, it's a Laravel route. It's dynamically generated in code.

          1 Reply Last reply Reply Quote 0
          • S
            scottalanmiller
            last edited by

            So to give a concrete example...

            I want requests going to / to be proxied to a service on another port. (This works in isolation.)

            And I want requests going to /api to be sent to the correct folder. But the PHP in that folder (the Laravel public folder) needs to think that there is still an /api trailing so that it routes it correctly.

            1 Reply Last reply Reply Quote 0
            • S
              stacksofplates
              last edited by

              Couldn't you just use a rewrite for this? Not at a computer but like

              rewrite ^/api /api
              
              S 1 Reply Last reply Reply Quote 0
              • S
                stacksofplates
                last edited by

                I've not used Laravel ever so that could be a dumb comment. I have no idea.

                S 1 Reply Last reply Reply Quote 0
                • S
                  scottalanmiller @stacksofplates
                  last edited by

                  @stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:

                  I've not used Laravel ever so that could be a dumb comment. I have no idea.

                  LOL

                  1 Reply Last reply Reply Quote 0
                  • S
                    scottalanmiller @stacksofplates
                    last edited by

                    @stacksofplates said in Nginx Config Need to Point Folder Reference Without Stripping:

                    Couldn't you just use a rewrite for this? Not at a computer but like

                    rewrite ^/api /api
                    

                    Maybe, I'll try it!

                    1 Reply Last reply Reply Quote 0
                    • 1 / 1
                    • First post
                      Last post