Issue with Directives

I am having an issue with trying to point to a specific path for a specific uri. Whenever I am using my LAN IP as the Host or when using the domain name, I wish for my specific path to be served over HTTPS.

My configuration can be found at nginx config · GitHub

Notably, I am trying to do an exact match on the /admin uri. However I keep receiving redirects when on port 80 (despite defining an exact match on line 18). When trying to access over port 443, I keep receiving a 404 response (despite defining an exact match on line 320).

I do have several other services running which may or may not be setup correctly, however this is the main issue I am trying to resolve at this time.

1 Like

Hi,

I’d recommend to enable debug log feature. Please read that document carefully.

Once enabled, the /var/log/nginx/error.log starts to received hundreds of messages related to how exactly nginx processing a request.

Hope that helps.

The error log doesn’t give details about which paths in the config file are taken, nor does it even indicate explicitly which uri was used.

No details in a log file means that it wasn’t configured properly.
How’s error_log directive is configured?

I didn’t say there were no details, I said that the path in the config file that is taken is not logged.

You can see my config file that was linked in the first post where error_log is not used. I still receive errors for other issues like bad php usage.

There’s no error_log directives in the provided configuration file.

Just to be clear, do you expect the /admin to be served over HTTP or do you expect it to be redirected to HTTPS? If you want to have it server over HTTP, the return directive can cause interesting behaviors in location blocks at times. Can you try moving the location / block below the other location blocks in that specific server block?

For the second part, are you seeing this behavior when hitting the /admin URI over HTTPS with the host IP and DNS name? When just using the IP, nginx will leverage the “first” server with HTTPS listeners, which probably would not be the one you expect. With the DNS name, the config looks OK so I am not sure why it is not matching the /admin location. Is there anything in the access log that could help? I assume the paths for the root and basic auth files are correct and have the correct privileges, so my best guess is that the request is getting caught either by the wrong location block or server configuration.