location для nginx

Статус
В этой теме нельзя размещать новые ответы.

xsacha

Только чтение
Сообщения
1,262
Реакции
1,383
Баллы
5,850
Помогите пожалуйста, не очень силен в nginx пытаюсь на него перейти. Есть сайта, а в папке сайта форум (xxx.ru/forum), как прописать location, сам сайт работает, а вот форум кроме главной странице нет, пишет 403 Forbidden и при переходе почему ссылка становится такого вида xxx.ru/forum/forums
 
Последнее редактирование:
location /forum {
some config;
}

т.е.
server
{
some basic config for main;
location / { some basic config; }
location /forum { some basic config; }
}


Если форум находится допустим в /home/example.com/forum ничего настраивать не нужно. Nginx будет сам все подхватывать. (если все в конфиге нормально)

Если форум находится допустим в /home/forum (но не в example.com) можно настроить alias для такого вида, с указанием что файлы находятся в /forum, а не в /
 
Последнее редактирование:
А сам форум где лежит, в той же папке где и сайт?
Нет сайт лежит тут /xxx.ru, а форум тут /xxx.ru/forum
если кидать что вы написали в секцию server isp орет ошибка синтаксиса
 
Последнее редактирование:
покажите весь конфиг (там же выше я просто пример написал как должно быть приблизительно, там нет конфига, только структура)
 
Видел переписывал так
Код:
location /forum/ {
    try_files $uri $uri/ forum/index.php?$uri&$args;
    index index.php index.html;
}

location /forum/internal_data/ {
    internal;
}
location /forum/library/ {
       internal;
}

не помогло

Код:
#user 'xsasha' virtual host 'news36.org' configuration file
server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
        location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
        location /ftp {
        rewrite ^(.*)$ ftp://news36.org redirect;
           }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }
         location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
         access_log off; log_not_found off; expires max;
                        }
        location /wp-config.php {
             deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
              }
        location /wp-login.php {
        allow 192.168.1.1;
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
             }
        location /forum/admin.php {
        allow 192.168.1.1;
        deny all;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
            location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
       location /forum {
       rewrite ^(.*)$ https://$http_host$request_uri redirect;
                 }
        location /forum/library/config.php {
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
      location ~ /(internal_data|library) {
        internal;
            }
    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:80;
                          }
        server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
        location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
       location /ftp {
       rewrite ^(.*)$ ftp://news36.org redirect;
           }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }
        location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off; log_not_found off; expires max;
                     }
        location /wp-config.php {
           deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
              }
        location /wp-login.php {
        allow 192.168.1.1;
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
             }
        location /forum/admin.php {
        allow 192.168.1.1;
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
        location /forum/library/config.php {
           deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }

    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:443;
    ssl on;
    ssl_certificate "/var/www/httpd-cert/xsasha/news36.org.crtca";
    ssl_certificate_key "/var/www/httpd-cert/xsasha/news36.org.key";
}
 
Последнее редактирование:
Видел переписывал так
Код:
location /forum/ {
    try_files $uri $uri/ forum/index.php?$uri&$args;
    index index.php index.html;
}

location /forum/internal_data/ {
    internal;
}
location /forum/library/ {
       internal;
}

не помогло

Код:
#user 'xsasha' virtual host 'news36.org' configuration file
server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
        location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
        location /ftp {
        rewrite ^(.*)$ ftp://news36.org redirect;
           }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }
         location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
         access_log off; log_not_found off; expires max;
                        }
        location /wp-config.php {
             deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
              }
        location /wp-login.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
             }
        location /forum/admin.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
            location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
       location /forum {
       rewrite ^(.*)$ https://$http_host$request_uri redirect;
                 }
        location /forum/library/config.php {
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
      location ~ /(internal_data|library) {
        internal;
            }
    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:80;
                          }
        server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
        location / {
            try_files $uri $uri/ /index.php?q=$request_uri;
       location /ftp {
       rewrite ^(.*)$ ftp://news36.org redirect;
           }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }
        location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off; log_not_found off; expires max;
                     }
        location /wp-config.php {
           deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
              }
        location /wp-login.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
             }
        location /forum/admin.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
        location /forum/library/config.php {
           deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }

    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:443;
    ssl on;
    ssl_certificate "/var/www/httpd-cert/xsasha/news36.org.crtca";
    ssl_certificate_key "/var/www/httpd-cert/xsasha/news36.org.key";
}

не так))) сейчас подправлю, и отредактирую это сообщение)
 
Да сайт сам на wordpress и требуется, чтобы word и xf работали, сейчас сайт работает xf нет
 
xsacha, у вас ISPmanager, вот такая конструкция подойдет:
Код:
    location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /library/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /internal_data/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
 
Вот конфиг может не правильно поставил, но не работает
Код:
#user 'xsasha' virtual host 'news36.org' configuration file
server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
        location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
        location /ftp {
        rewrite ^(.*)$ ftp://news36.org redirect;
           }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
        }
         location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
         access_log off; log_not_found off; expires max;
                        }
        location /wp-config.php {
             deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
              }
        location /wp-login.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
             }
        location /forum/admin.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
            location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
       location /forum {
       rewrite ^(.*)$ https://$http_host$request_uri redirect;
                 }
        location /forum/library/config.php {
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
    location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /library/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /internal_data/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:80;
                          }

Ссылки при переходе такие , а должны быть такие
 
xsacha, конечно неправильно. У вас локейшн forum три раза вроде как задается.
Код:
       location /forum {
       rewrite ^(.*)$ https://$http_host$request_uri redirect;
                 }
        location /forum/library/config.php {
         deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
                 }
Убрать.
 
Убрал все равно ссылка не верна и кэшь почистил
 
Ссылки при переходе такие , а должны быть такие
В каком месте они "должны"? Ссылки и должны быть именно как в первом варианте. forum - папка ваша, а forums - это движок подставляет чтобы форум показать, для тем там threads и т.п. Так что если в варианте с такой "двойной" ссылкой все работает - то все верно настроено. Второй вариант ссылок будет только если у вас форум в корне, никак иначе.
 
При первом вариант он пишет 404 Not Found, вы же сами можете посмотреть. Работает только главная страница и так почти с любой cms, которую настраиваю. Только главная и все.
 
Последнее редактирование:
Я просто не представляю как так можно было расставить переносы, чтобы конфиг nginx настолько сложно читался...

Правим переносы только и сразу видим просто кучу лишнего:
Код:
#user 'xsasha' virtual host 'news36.org' configuration file
server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
    location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
        location /ftp {
            rewrite ^(.*)$ ftp://news36.org redirect;
        }
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
         access_log off; log_not_found off; expires max;
    }
    location /wp-config.php {
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /wp-login.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /forum/admin.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
            location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /forum {
       rewrite ^(.*)$ https://$http_host$request_uri redirect;
    }
    location /forum/library/config.php {
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /library/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /internal_data/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:80;
}
Ну а теперь выкидываем откровенный мусор, получаем что-то такое:
Код:
#user 'xsasha' virtual host 'news36.org' configuration file
server {
    server_name news36.org www.news36.org;
    charset off;
    disable_symlinks if_not_owner from=$root_path;
    index index.html index.php;
    root $root_path;
    set $root_path /var/www/xsasha/data/www/news36.org;
    ssi on;
    access_log /var/www/httpd-logs/news36.org.access.log ;
    error_log /var/www/httpd-logs/news36.org.error.log notice;
    include /etc/nginx/vhosts-includes/*.conf;
    location / {
        try_files $uri $uri/ /index.php?q=$request_uri;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ~* ^.+.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
        access_log off;
        log_not_found off;
        expires max;
    }
    location /wp-config.php {
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /wp-login.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /forum/ {
        try_files $uri $uri/ /forum/index.php?$uri&$args;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /library/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location ^~ /internal_data/ {
        internal;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location /forum/admin.php {
        allow 212.193.169.1;
        allow 192.168.1.1;
        deny all;
        rewrite ^(.*)$ https://$http_host$request_uri redirect;
        location ~ [^/]\.ph(p\d*|tml)$ {
            try_files /does_not_exists @php;
        }
    }
    location @fallback {
        error_log /dev/null crit;
        access_log off ;
    }
    location @php {
        fastcgi_index index.php;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
        fastcgi_pass unix:/var/www/php-fpm/xsasha.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        try_files $uri =404;
        include fastcgi_params;
    }
    listen 192.168.1.36:80;
}
Если и этот вариант не подойдет, то я прям не знаю. Не сталкивался с необходимостью сращивать ЧПУ Wordpress и XenForo и поэтому надо чисто методом проб.
 
Спасибо огромное все заработало, просто в isp две секции обычная по 80 порту и защищенная 443 (скажи там). Я добавил в одну, а надо еще дублировать все во вторую и все заработало.
 
Статус
В этой теме нельзя размещать новые ответы.
Современный облачный хостинг провайдер | Aéza
Назад
Сверху Снизу