Runcloud nginx try_files help!


Can 2 try_files be present in a single location block?

Can I use break; or last; in location block? (not rewrite).

What I’m basically trying to do is:

location / {
    try_files $uri $uri/ =404; //How can i break here?
    try_files $uri $uri/ /index.php$is_args$args;



You can safely remove this and handle 404 errors in php instead of nginx.

Here is a straightforward way to handle 404 in php


That is not what I’m looking for. :confused:
I’m not using php but plain html. I wants to do it on server level.


Can you describe what are you exactly aiming at?

Just for reference purposes,


I use RunCloud to manage my server, I’m trying move to Native NGINX.

RC ads this config in server block.

location / {
    include /etc/nginx-rc/extra.d/app-heathcote.location.root.*.conf;
    try_files $uri $uri/ /index.php$is_args$args;

But I’ve problem with it. The problem is:

try_files $uri $uri/ /index.php$is_args$args;

This basically tells nginx if a non-exits directory/files found move the request to index.php

Now, this trouble for me. I don’t want to redirect non-exits page/file to index.php
I wants to throw 404.

Now, I can basically edit that line with this line:

try_files $uri $uri/ =404;

This is gonna solve my problem. But I don’t want to edit main.conf, because it is not recommended. But the recommended way to do is by adding rules in this file:


How can I accomplish this?


What are the contents of


The break; and last; only works in rewrites not on a location block.



If I wants to add custom rules, I can create a file and add those rules in there.


For example:

I can create


Those rules will be included in the location / block. Because of this line:

include /etc/nginx-rc/extra.d/app-heathcote.location.root.*.conf;


if nginx is handling just one website then there is no need to do the 404. You can maybe intercept errors and set error pages accordingly?


location ~ .php {
error_page /404.html


I’m not using php. vanilla html.


If that’s the case then,

Remove this and use the 404 block and it’ll be just fine for you.


I can remove it. But removing will cause trouble in the future. Becuse runcloud cleary mentioned when the rc-agent-bot gets updated all the modification will be wiped out.

That’s why I don’t wanna edit the main.conf.

I need to find a different approach, without modifying main.conf


You’re moving to native nginx right?

why will you configure runcloud nginx when you’re already going to take matter in your own hands?


I’m not. I’m not leaving RC. RC is more than just a stack.


Are you really?

If not then contact runcloud support to give you some sort of resolution. I don’t know how it works.


it works the same way nginx works.


Nginx doesn’t override their configurations over updates :slight_smile:


Nope. But runcloud’s agent does. The agent is just a handler. They do things on our behalf.

I know you hate RC, SP. But not everyone is linux-friendly. I hate using terminal. I try to avoid as much as possible.


See, Let’s get things clear.
I’m not hating their service but none of my recommendations are going to work for you because they don’t let configs remain there. If you are using standard nginx, that doesn’t happen at all and if nginx is not overriding the configs then you have to stop the 3rd party doing it. I don’t have a soultion for a nginx problem that isn’t being caused by nginx.