Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

classic Classic list List threaded Threaded
6 messages Options
xrd
Reply | Threaded
Open this post in threaded view
|

Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

xrd
I have installed Wordpress in a subdirectory - /var/www/html/stage

I am getting the following error in the error log. I think the filename
being passed has the subdirectory name prepended, which should not happen.

-----

2019/12/20 15:34:00 [error] 22393#22393: *10 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 110.227.251.142, server: mywebsite.com, request: "GET
/stage/%20https://mywebsite.com/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 01
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 06
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 00
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 01
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 00
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 51
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 07
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record byte: 00
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi record length: 81
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi parser: 0
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi header: "Status:
404 Not Found"
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi parser: 0
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi header:
"Content-type: text/html; charset=UTF-8"
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi parser: 1
2019/12/20 15:34:00 [debug] 22393#22393: *10 http fastcgi header done
2019/12/20 15:34:00 [debug] 22393#22393: *10 HTTP/1.1 404 Not Found



---/etc/nginx/sites-enabled/default looks like this

server {   # We're deliberately leaving this as-is to avoid conflict at the
moment

    root /var/www/html;
    server_name mywebsite.com www.mywebsite.com;
#    rewrite ^/moodle/(.*\.php)(/)(.*)$ /moodle/$1?file=/$3 last;
#    rewrite ^(..php)(/)(.)$ $1?file=/$3 last;    
    index  index.php index.html index.htm login.php;
# if you get errors enable the line below and find out errors in the log
file.
#    error_log /var/log/nginx/error.log notice;
   
     location / {
  index  index.php index.html index.htm login.php;
        try_files $uri  /index.php?$args;
    }

    location ~ \.php$ {
        try_files $uri  /index.php?$args;
        try_files $uri $script_name =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php7.0-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

     location /fpelms {
        root /var/www/html;        
  index  index.php index.html index.htm login.php;
    }

     location /stage {
    root /var/www/html;
    index index.php;

                if (!-e $request_filename) {
        rewrite  ^(.*)$  /stage/index.php?q=$1  last;
      }
    }

   
      location /doc/ {
        alias /usr/share/doc/;
        autoindex on;
        allow 127.0.0.1;
        deny all;
    }

    location ~/\.ht {
        deny all;
    }


    location /remotech.html {
        proxy_pass https://outsidedomain.com/;
        }

    location /static {
        proxy_pass https://outsidedomain.com/static/;
      }

     location /api/ {
         proxy_pass https://outsidedomain.com/api/;
       }

     location /firebase-messaging-sw.js{
              proxy_pass
https://outsidedomain.com/firebase-messaging-sw.js;
       }

       location /manifest.json{
              proxy_pass https://outsidedomain.com/manifest.json;
       }

      location /plugins {
              proxy_pass https://outsidedomain.com/plugins/;
       }

        location /scripts {
              proxy_pass https://outsidedomain.com/scripts/;
       }

       location /styles {
              proxy_pass https://outsidedomain.com/styles/;
       }


       location /assets {
              proxy_pass https://outsidedomain.com/assets/;
       }

       location /fonts {
              proxy_pass https://outsidedomain.com/fonts/;
       }


    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pem; #
managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/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




}



server {
    if ($host = www.mywebsite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = mywebsite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    server_name mywebsite.com www.mywebsite.com;
    return 404; # managed by Certbot


}

----------

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286524,286524#msg-286524

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

Francis Daly
On Fri, Dec 20, 2019 at 06:32:58AM -0500, vikask wrote:

Hi there,

> I am getting the following error in the error log. I think the filename
> being passed has the subdirectory name prepended, which should not happen.

The http request that is logged looks strange to me. Is the "referrer"
value reliable? If so, check the html returned there to see what the
"img src" looks like there.

> client: 110.227.251.142, server: mywebsite.com, request: "GET
> /stage/%20https://mywebsite.com/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
> HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
> "fp-academy.in", referrer: "https://fp-academy.in/stage/"

(This does not address any of the nginx config; but it's simplest to
fix one thing at a time. Maybe there is only one thing that needs fixing!)

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
xrd
Reply | Threaded
Open this post in threaded view
|

Re: Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

xrd
Hi Francis...

Here is the error log

2019/12/21 18:16:01 [error] 23708#23708: *1821 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 73.218.245.139, server: fp-academy.in, request: "GET
/stage/%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/21 18:16:02 [error] 23708#23708: *1826 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 73.218.245.139, server: fp-academy.in, request: "GET
/stage/%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/21 18:16:03 [error] 23708#23708: *1821 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 73.218.245.139, server: fp-academy.in, request: "GET /favicon.ico
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/21 18:16:09 [error] 23708#23708: *1838 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 116.73.20.16, server: fp-academy.in, request: "GET
/stage/%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/21 18:16:10 [error] 23708#23708: *1838 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 116.73.20.16, server: fp-academy.in, request: "GET
/stage/%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in", referrer: "https://fp-academy.in/stage/"
2019/12/21 18:16:11 [error] 23708#23708: *1837 FastCGI sent in stderr:
"Primary script unknown" while reading response header from upstream,
client: 116.73.20.16, server: fp-academy.in, request: "GET /favicon.ico
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host:
"fp-academy.in"

-----------------------------------
Here is the listing of the directory

#ls -lsa /var/www/html/stage/wp-content/uploads/2019/11/hp*

364 -rwxrwxrwx 1 www-data www-data 368698 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-1030x547.jpg
312 -rwxrwxrwx 1 www-data www-data 317903 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-1210x423.jpg
356 -rwxrwxrwx 1 www-data www-data 361355 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x430.jpg
520 -rwxrwxrwx 1 www-data www-data 531659 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x630.jpg
652 -rwxrwxrwx 1 www-data www-data 667035 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
 32 -rwxrwxrwx 1 www-data www-data  29744 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-180x180.jpg
 44 -rwxrwxrwx 1 www-data www-data  42398 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-260x185.jpg
 44 -rwxrwxrwx 1 www-data www-data  42039 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-300x159.jpg
  4 -rwxrwxrwx 1 www-data www-data   2710 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-36x36.jpg
140 -rwxrwxrwx 1 www-data www-data 140912 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-495x400.jpg
192 -rwxrwxrwx 1 www-data www-data 193974 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-705x375.jpg
192 -rwxrwxrwx 1 www-data www-data 194602 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-710x375.jpg
220 -rwxrwxrwx 1 www-data www-data 221598 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-768x408.jpg
  8 -rwxrwxrwx 1 www-data www-data   7239 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-80x80.jpg
188 -rwxrwxrwx 1 www-data www-data 192062 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-845x321.jpg
336 -rwxrwxrwx 1 www-data www-data 343025 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg-845x684.jpg
220 -rwxrwxrwx 1 www-data www-data 224100 Nov 26 11:29
/var/www/html/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg

-------------------------------------
And Here is the source of the page.

</header>
               
        <div id='main' class='all_colors' data-scroll-offset='88'>

        <div id='layer_slider_1'  class='avia-layerslider main_color avia-shadow
avia-builder-el-0  el_before_av_layout_row  avia-builder-el-first
container_wrap fullsize' style='  height: 851px; max-width: 1410px; margin:
0 auto;' ><div id="layerslider_1" class="ls-wp-container fitvidsignore"
style="width:1410px;height:850px;margin:0 auto;margin-bottom: 0px;"><div
class="ls-slide" data-ls="bgsize:cover;bgposition:50%
50%;duration:7000;transition3d:all;kenburnsscale:1.1;"><img width="1600"
height="850"
src="https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg"
class="ls-bg" alt=""
srcset="%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg
1600w,
%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-300x159.jpg
300w,
%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-768x408.jpg
768w,
%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1030x547.jpg
1030w,
%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
1500w,
%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-705x375.jpg
705w" sizes="(max-width: 1600px) 100vw, 1600px" /><div
style="width:300%;height:100%;top:0px;left:-800px;background-color:rgba(0,
0, 0, 0.6);" class="ls-l"
data-ls="durationin:500;durationout:500;parallaxlevel:0;"></div><h1
style="font-weight:normal;
;font-family:Arial;font-size:90px;color:#ffffff;top:286px;left:320px;"
class="ls-l"
data-ls="durationin:1500;delayin:900;easingin:easeInOutBack;rotatexin:90;transformoriginin:50%
0% 0;durationout:400;parallax:true;parallaxlevel:10;">WELCOME</h1><p
style="text-transform:uppercase;font-family:Arial;font-size:30px;color:#ffffff;top:385px;left:328px;font-weight:600;"
class="ls-l"
data-ls="durationin:1500;delayin:2200;easingin:easeInOutBack;rotatexin:-90;transformoriginin:0%
0% 0;durationout:400;parallax:true;parallaxlevel:10;">To Henkel Flexible
Packaging Academy</p><p
style="text-transform:uppercase;display:block;padding-top:3px;padding-right:3px;padding-bottom:1px;padding-left:3px;font-family:Arial;font-size:23px;color:rgba(0,
0, 0, 0.6);top:443px;left:332px;background-color:#ffffff;" class="ls-l"
data-ls="durationin:1500;delayin:2800;easingin:easeInOutBack;rotatexin:-90;transformoriginin:0%
0%
0;durationout:400;easingout:easeInOutBack;parallax:true;parallaxlevel:10;">Educate</p><p
style="text-transform:uppercase;display:block;padding-top:3px;padding-right:3px;padding-bottom:1px;padding-left:3px;font-family:Arial;font-size:23px;color:rgba(0,
0, 0, 0.6);top:443px;left:474px;background-color:#ffffff;" class="ls-l"
data-ls="durationin:1500;delayin:3500;easingin:easeInOutBack;rotatexin:-90;transformoriginin:0%
0%
0;durationout:400;easingout:easeInOutBack;parallax:true;parallaxlevel:10;">Innovate</p><p
style="text-transform:uppercase;display:block;padding-top:3px;padding-right:3px;padding-bottom:1px;padding-left:3px;font-family:Arial;font-size:23px;color:rgba(0,
0, 0, 0.6);top:443px;left:625px;background-color:#ffffff;" class="ls-l"
data-ls="durationin:1500;delayin:4300;easingin:easeInOutBack;rotatexin:-90;transformoriginin:0%
0%
0;durationout:400;easingout:easeInOutBack;parallax:true;parallaxlevel:10;">Collaborate</p></div></div></div>
<div id='3-col-intro'  class='av-layout-grid-container entry-content-wrapper
main_color av-flex-cells     avia-builder-el-1  el_after_av_layerslider
el_before_av_layout_row  submenu-not-first container_wrap fullsize' style='
'  >
<div class="flex_cell no_margin av_one_third  avia-builder-el-2
el_before_av_cell_one_third  avia-builder-el-first   "
style='vertical-align:top; padding:70px 50px 70px 50px ; '><div
class='flex_cell_inner' >
<article  class="iconbox iconbox_left_content    avia-builder-el-3
avia-builder-el-no-sibling  av-icon-style-no-border"  itemscope="itemscope"
itemtype="https://schema.org/CreativeWork" ><div class="iconbox_icon
heading-color " aria-hidden='true' data-av_icon=''
data-av_iconfont='entypo-fontello'  style='background-color:#ed1c24;
border:1px solid #ed1c24; color:#ffffff; ' ></div><div
class="iconbox_content"><header class="entry-content-header"><h3
class='iconbox_content_title  '  itemprop="headline"  >Peerless
Course</h3></header><div class='iconbox_content_container  '
itemprop="text"  ><p>Training modules include practical hands-on experience
on industrial lamination machines, with classroom sessions for theory</p>
</div></div><footer class="entry-footer"></footer></article>

I am sorry the message is appearing a little clumsy.. the option of
attaching a file.would have been great..


Regards
Vikas

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286530,286532#msg-286532

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

Francis Daly
On Sat, Dec 21, 2019 at 07:58:50AM -0500, vikask wrote:

Hi there,

The request getting to nginx is:

> /stage/%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg

That is almost certainly wrong. The request probably should be just

/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg

Do things work if you just request that url?


> <img width="1600"
> height="850"
> src="https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg"
> class="ls-bg" alt=""
> srcset="%20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg.jpg

Edit that (and the rest of this "srcset" collection) and replace the
%20 before each https:// with just a space.

(And if this content is generated -- edit whatever the source is so that
when this content is generated, there is no %20 at the start of a url.)

> 1600w,
> %20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-300x159.jpg
> 300w,
> %20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-768x408.jpg
> 768w,
> %20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1030x547.jpg
> 1030w,
> %20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-1500x797.jpg
> 1500w,
> %20https://fp-academy.in/stage/wp-content/uploads/2019/11/hp_slider_bg-705x375.jpg
> 705w" sizes="(max-width: 1600px) 100vw, 1600px" />

It may be that your nginx config works as it should, already.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
xrd
Reply | Threaded
Open this post in threaded view
|

Re: Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

xrd
Hi there,

Thanks for showing me the direction.
I removed the block i had created for the subdirectory /stage in the default
nginx file.
the default Home URL had a space [typing mistake] and so the 20% was being
sent in the URL.

Wonder what i would have done without your debugging skills.
Thank you for your super diagnosis!

Appreciate it!
Regards
Vikas

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,286530,286535#msg-286535

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Wordpress not able to display theme properly - FastCGI sent in stderr: "Primary script unknown"

Francis Daly
On Sun, Dec 22, 2019 at 09:43:47AM -0500, vikask wrote:

Hi there,

great that you now have a  config+system that works for you.

> I removed the block i had created for the subdirectory /stage in the default
> nginx file.
> the default Home URL had a space [typing mistake] and so the 20% was being
> sent in the URL.

And thanks for sharing the eventual fix -- that will probably help the
next person with the same issue.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx