Advertisement:

Author Topic: Osclass permalinks with nginx and ispconfig  (Read 97 times)

urmitnick

  • Jr. Member
  • **
  • Posts: 55
Osclass permalinks with nginx and ispconfig
« on: August 08, 2019, 02:20:47 am »
Hi everyone,

I know that Osclass permalinks issues with nginx was discussed several times, since the first days of osclass. But the problem is still occuring for many people without a definitive solution from  osclass devs.

I've tried all the suggested solution in topics from 2012 till now. And what I discovered is that some solutions may work with some themes and sometimes some pages but not others!! e.g.:

Code: [Select]
location / {try_files $uri $uri/ /index.php?$args;}

Adding this directive to my nginx virtualhost, make all my site with bender theme works except that when I click publish when adding ads, and  when I click on a subcategories I get 404 error, same thing with search.

But this directive doesn't work with sakela theme (which is my main theme): 404 error for most pages and 500 error for login page!

While adding this directive, makes sakela theme work (not with bender) but still having some errors.

Code: [Select]
location / {
index index.php index.html index.htm;
if($_SERVER['REQUEST_URI'] == "/index.php") {
header("Location: /",TRUE,301);
exit();}
}

Current issues with this code: error 404 when accessing subcategories, clicking publish, accessing the newly added ad (after error 404), search page....


Any ideas and solutions??

Regards,

navjottomer

  • Tutor
  • Sr. Member
  • *
  • Posts: 378
  • I am here
Re: Osclass permalinks with nginx and ispconfig
« Reply #1 on: August 08, 2019, 02:42:14 am »
Code: [Select]
location / {
try_files $uri $uri/ /index.php?$query_string;
}
This always worked with me and my clients. I hope it will work on yours too.

urmitnick

  • Jr. Member
  • **
  • Posts: 55
Re: Osclass permalinks with nginx and ispconfig
« Reply #2 on: August 08, 2019, 04:19:06 am »
Code: [Select]
location / {
try_files $uri $uri/ /index.php?$query_string;
}
This always worked with me and my clients. I hope it will work on yours too.

Thank you for your answer, but it gives me the same errors as directives I've used.

navjottomer

  • Tutor
  • Sr. Member
  • *
  • Posts: 378
  • I am here
Re: Osclass permalinks with nginx and ispconfig
« Reply #3 on: August 08, 2019, 02:22:15 pm »
I think there are other rules which are interfering with your config. It would be better if you post your whole config.

urmitnick

  • Jr. Member
  • **
  • Posts: 55
Re: Osclass permalinks with nginx and ispconfig
« Reply #4 on: August 08, 2019, 03:42:39 pm »
I think there are other rules which are interfering with your config. It would be better if you post your whole config.

Thank ypu for you reply. Here is my vhost file's content:

Code: [Select]
server {
        listen 167.86.103.189:80;
        listen 167.86.103.189:443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_certificate /var/www/clients/client3/web10/ssl/madariss.info-le.crt;
        ssl_certificate_key /var/www/clients/client3/web10/ssl/madariss.info-le.key;

        server_name madariss.info *.madariss.info;

        root   /var/www/madariss.info/web/;

        if ($http_host = "madariss.info") {
            rewrite ^ $scheme://www.madariss.info$request_uri? permanent;
        }
        if ($scheme != "https") {
            rewrite ^ https://$http_host$request_uri? permanent;
        }


        index index.html index.htm index.php index.cgi index.pl index.xhtml;


        location ~ \.shtml$ {
            ssi on;
        }


        error_page 400 /error/400.html;
        error_page 401 /error/401.html;
        error_page 403 /error/403.html;
        error_page 404 /error/404.html;
        error_page 405 /error/405.html;
        error_page 500 /error/500.html;
        error_page 502 /error/502.html;
        error_page 503 /error/503.html;
        recursive_error_pages on;
        location = /error/400.html {

            internal;
        }
        location = /error/401.html {

            internal;
        }
        location = /error/403.html {

            internal;
        }
        location = /error/404.html {

            internal;
        }
        location = /error/405.html {

            internal;
        }
        location = /error/500.html {

            internal;
        }
        location = /error/502.html {

            internal;
        }
        location = /error/503.html {

            internal;
        }

        error_log /var/log/ispconfig/httpd/madariss.info/error.log;
        access_log /var/log/ispconfig/httpd/madariss.info/access.log combined;

        location ~ /\. {
deny all;
        }

        location ^~ /.well-known/acme-challenge/ {
access_log off;
log_not_found off;
auth_basic off;
root /usr/local/ispconfig/interface/acme/;
autoindex off;
index index.html;
try_files $uri $uri/ =404;
        }

        location = /favicon.ico {
            log_not_found off;
            access_log off;
            expires max;
            add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        location = /robots.txt {
            allow all;
            log_not_found off;
            access_log off;
        }

        location /stats/ {

            index index.html index.php;
            auth_basic "Members Only";
            auth_basic_user_file /var/www/clients/client3/web10/web//stats/.htpasswd_stats;
        }

        location ^~ /awstats-icon {
            alias /usr/share/awstats/icon;
        }

        location ~ \.php$ {
            try_files /f923xxxxxxxxxxxxxxxx3307611xxx.htm @php;
        }

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_pass unix:/var/lib/php7.2-fpm/web10.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }

        location /cgi-bin/ {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            root /var/www/clients/client3/web10;
            gzip off;
            fastcgi_pass  unix:/var/run/fcgiwrap.socket;
            fastcgi_index index.cgi;
            fastcgi_param DOCUMENT_ROOT /web;
            fastcgi_param HOME /web;
            fastcgi_param SCRIPT_FILENAME /web$fastcgi_script_name;
            fastcgi_intercept_errors on;
        }



        location / {
        try_files $uri $uri/ /index.php?$query_string;
        }


        location /phpmyadmin {
                       root /usr/share/;
                       index index.php index.html index.htm;
                       location ~ ^/phpmyadmin/(.+\.php)$ {
                               try_files $uri =404;
                               root /usr/share/;
                               fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                               fastcgi_param HTTPS $fastcgi_https; # <-- add this line
                               fastcgi_index index.php;
                               fastcgi_param SCRIPT_FILENAME $request_filename;
                               include /etc/nginx/fastcgi_params;
                               fastcgi_param PATH_INFO $fastcgi_script_name;
                               fastcgi_buffer_size 128k;
                               fastcgi_buffers 256 4k;
                               fastcgi_busy_buffers_size 256k;
                               fastcgi_temp_file_write_size 256k;
                               fastcgi_intercept_errors on;
                       }
                       location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                               root /usr/share/;
                       }
        }
        location /phpMyAdmin {
                       rewrite ^/* /phpmyadmin last;
        }


        location /roundcube {
                       root /usr/share/;
                       index index.php index.html index.htm;
                       location ~ ^/roundcube/(.+\.php)$ {
                               try_files $uri =404;
                               root /usr/share/;
                               fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                               fastcgi_param HTTPS $fastcgi_https; # <-- add this line
                               fastcgi_index index.php;
                               fastcgi_param SCRIPT_FILENAME $request_filename;
                               include /etc/nginx/fastcgi_params;
                               fastcgi_param PATH_INFO $fastcgi_script_name;
                               fastcgi_buffer_size 128k;
                               fastcgi_buffers 256 4k;
                               fastcgi_busy_buffers_size 256k;
                               fastcgi_temp_file_write_size 256k;
                               fastcgi_intercept_errors on;
                       }
                       location ~* ^/roundcube/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
                               root /usr/share/;
                       }
        }
        location /webmail {
                       rewrite ^/* /roundcube last;
        }




}