Welcome! Log In Create A New Profile

Advanced

Nginx does not serve/proxy path if it is missing ending slash

Posted by postcd 
Nginx does not serve/proxy path if it is missing ending slash
May 24, 2023 12:59AM
Hello dear Nginx users, being amateur user I wanted to ask You for your help.

My Nginx configuration is properly serving a webpage when visiting:
server.my.name
my.name
my.name/rooms
my.name/room/abc
my.name/r/abc/

but not when i visit:
my.name/r/abc
(note that same path works when it has trailing slash)

without slash, it redirects to http://127.3.2.1:4242/r/abc/

my configuration file is:

# cat /etc/nginx/nginx.conf
[quote]
#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
access_log off;
access_log /var/log/nginx/access.log;
#access_log logs/access.log main;
error_log on;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/sites-enabled/*;

server {
server_name 127.0.0.1 server.my.name;
listen 80;
listen [::]:80;
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/my.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

location / {
root /var/www/html;
}

index index-server-var-www.html index.htm index.php
try_files $uri $uri/ =404;

location ~ /\.ht {
deny all;
}

location = /favicon.ico {
log_not_found off;
access_log off;
}
}

server {
server_name https my.name www.my.name;
client_max_body_size 10M;
location /static/ {
autoindex off;
root /usr/lib/python3/dist-packages/sogs;
# try_files $uri /404.html;
# error_page 404 =200 /404.html;
}
location = /404.html {
root /var/lib/session-open-group-server;
}
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.3.2.1:4242$request_uri;
# try_files $uri $uri/ =404;
# if ($request_uri = "?public_key=") { return 301 /; }
}
listen 80;
listen [::]:80;
listen 443 ssl; # managed by Certbot
listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/my.name/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/my.name/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

# error_page 404 /404.html;
# error_page 404 =200 /404.html;
# try_files $uri /404.html;

}
}[/quote]

Since i think that i am not linking to any other .conf files, issue must be in above file, but where to correct it please?
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 328
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready