Answer the question
In order to leave comments, you need to log in
Why doesn't nginx take a more appropriate location?
I don't understand why a redirect is not being made from the forum to the desired page. As I understand it, nginx should handle the most matching location. That is, if a request comes in site123435654.ru/forum/ , then it should take the /forum/ location, and it takes and goes to the / location for some reason. The config is like this:
server {
listen 80;
server_name site123435654.ru www.site123435654.ru;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
listen 443 ssl;
keepalive_timeout 70;
keepalive_requests 150;
server_name site123435654.ru www.site123435654.ru;
set $server_root /usr/portal5/www;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/ssl/dhparam.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
ssl_certificate /etc/ssl/certs/key.crt;
ssl_certificate_key /etc/ssl/private/key2021.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
server_name_in_redirect off;
access_log /var/log/nginx/access.log main;
index index.php;
error_page 500 502 503 504 /500.html;
error_page 404 = /404.php;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
client_max_body_size 1024M;
client_body_buffer_size 4M;
proxy_set_header HTTPS YES;
add_header X-Frame-Options SAMEORIGIN;
location / {
root $server_root;
expires modified 2d;
if ($request_method = OPTIONS) {proxy_pass http://upstream;}
if ($request_method = PROPFIND) {proxy_pass http://upstream;}
if ($request_method = PROPPATCH) {proxy_pass http://upstream;}
if ($request_method = MKCOL) {proxy_pass http://upstream;}
if ($request_method = COPY) {proxy_pass http://upstream;}
if ($request_method = MOVE) {proxy_pass http://upstream;}
if ($request_method = LOCK) {proxy_pass http://upstream;}
if ($request_method = UNLOCK) {proxy_pass http://upstream;}
if ($request_method = PUT) {proxy_pass http://upstream;}
}
location /forum/
{
return 301 https://site12345678.ru/1/2/;
}
}
location =/forum/
{
return 301 https://site12345678.ru/1/2/;
}
Answer the question
In order to leave comments, you need to log in
Rewrite the config in a human way, you can start with this configurator .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question