NGINX page shows raw content instead of HTML - php

I am using NGINX 1.12 with PHP-FPM on AWS server.
I get a rare scenario bug that sometimes my page shows the html content along with headers with 0 prefixed and suffixed
0
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate
Content-Type: text/html; charset=utf-8
Date: Mon, 26 Nov 2018 05:29:29 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
transfer-encoding: chunked
Connection: keep-alive
html content
0
When i refresh immediately or later, this will show the proper page.
Can anyone suggest what may be the issue ?

Related

Wordpress Site not Connecting thru online Cron Job Service

I am running a wordpress site and using an online cron job service to connect.
When i connect thru the service im getting "HTTP/1.1 404 Not Found" error.
This is the cron job link im using:
http://www.moongot.com/wp-content/plugins/WPFanMachineBasic/auto.php
This is the output:
X-Powered-By: PHP/5.5.22 Pragma: no-cache Date: Sat, 14 Apr 2018
22:00:59 GMT Content-Length: 4 Server: Apache/2 Set-Cookie:
PHPSESSID=3ef1b912c68e0502d03caccb87e0858b; path=/ Expires: Wed, 11
Jan 1984 05:00:00 GMT Cache-Control: no-cache, must-revalidate,
max-age=0 X-Endurance-Cache-Level: 2 Content-Type: text/html;
charset=UTF-8
DONE
I get the same via cURL:
curl -I http://www.moongot.com/wp-content/plugins/WPFanMachineBasic/auto.php
HTTP/1.1 404 Not Found
Date: Sat, 14 Apr 2018 22:29:13 GMT
Content-Type: text/html
Content-Length: 863
Connection: keep-alive
Keep-Alive: timeout=30
Server: Apache/2
X-Powered-By: PHP/5.5.22
Set-Cookie: PHPSESSID=2df00eb1132bf607a708d00aee845f8a; path=/
Pragma: no-cache
Expires: Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-cache, must-revalidate, max-age=0
Last-Modified: Wed, 02 Aug 2017 19:17:35 GMT
Accept-Ranges: bytes
and in Chrome:
So you'll want to figure out why your auto.php file is spitting out a 404 header.

goutte - guzzle: Not getting file download after form submission

I am using goutte to click a button in a form and get the download link for a file. I am correctly logged in the website.
The code I am using is what already worked in other parts of the page and gave me the right results until this point, but in this case I'm not sure it's enough:
$form = $crawler->selectButton('btn_name')->form();
$tableResults = $this->client->submit($form);
$result = $client->getResponse()->getContent(); // contains the same page of the form
The button sets some parameters and sends the request via ajax (since the page does not reload after posts):
<button id="btn_id_was_long" name="btn_name" onclick="PrimeFaces.ab({source:'btn_name'});return false;" type="submit"><span>DAE</span></button>
When I inspect the content of the response though I get the html page that contains the form but there is no trace of an attachment.
When the button is clicked with the above code I get the following headers in response:
Date: Tue, 08 Nov 2016 16:37:42 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips DAV/2 mod_jk/1.2.31
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1
Liferay-Portal: Liferay Portal Enterprise Edition 6.2.10 EE GA1 (Newton / Build 6210 / November 1, 2013)
X-JAVAX-PORTLET-FACES-NAMESPACED-RESPONSE: true X-Powered-By: JSP/2.2
Transfer-Encoding: chunked Content-Type: text/html;charset=UTF-8
When I perform the same action in the browser I get this instead, with the file download:
HTTP/1.1 200 OK
Date: Tue, 08 Nov 2016 17:31:34 GMT
Server: Apache/2.2.29 (Unix) mod_ssl/2.2.29 OpenSSL/1.0.1e-fips DAV/2 mod_jk/1.2.31
x-content-type-options: nosniff
x-frame-options: SAMEORIGIN
X-XSS-Protection: 1
Content-Encoding: gzip
Liferay-Portal: Liferay Portal Enterprise Edition 6.2.10 EE GA1 (Newton / Build 6210 / November 1, 2013)
Content-Disposition: attachment;filename=DAE_00001_17/10/2016.pdf
Expires: 0
Pragma: public
Cache-Control: must-revalidate, post-check=0, pre-check=0 portlet.http-status-code: 200
Keep-Alive: timeout=5, max=99
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: application/pdf;charset=UTF-8
Any clue what I'm doing wrong?

Magento does not set cookie on product/category page

So here is the issue, Magento doesn't seem to set-cookie on product/category page.
It doesn't show any cart items or customer login information on product page, however all the items appear fine on home page and rest of the pages on site.
I checked headers for two of the pages.
Here is the product page:
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:01:57 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Here is the home page headers (which is working fine)
HTTP/1.1 200 OK
Server: nginx/1.8.1
Date: Tue, 15 Mar 2016 05:02:12 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
X-Frame-Options: SAMEORIGIN
Set-Cookie: frontend=n7m2mbnoo861h84r9ma40of221; expires=Wed, 16-Mar-2016 05:02:12 GMT; path=/store/; domain=-----; HttpOnly
Vary: Accept-Encoding
X-Cacheable: NO:Cache-Control=no-cache
Accept-Ranges: bytes
X-Served-From-Cache: Yes
Any idea what's happening?
I have tried increasing cookie lifetime to 86400
and cookie path to /store/ and cookie domain to (www.mydomain.com)
It turns out issue was misconfiguration of varnish on server. It was serving cached pages. Solution: Restarted varnish.

multiple PHPSESSID cookies and browser doesn't keep any

I'm getting 2 PHPSESSID set cookies headers from a login request from my yii application.
Date: Thu, 05 Dec 2013 02:19:44 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3
Set-Cookie: PHPSESSID=3lkhjlsv967n56horpcl3n7gl5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: PHPSESSID=sctb6cd1snbd5g2esv1mn2lug7; path=/
Content-Length: 3
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
And browser doesn't keep any and doesn't send back them for future requests. Any idea how this is happening?

Page is downloaded instead of rendered over SSL

I have my checkout page secured on my site with the Bluehost SSL certificate and quite frequently the page will be downloaded instead of rendered.
This only happens when I use ssl, if I run the site without it the page loads fine.
Is there anything i can do to prevent this, I have tried placing
<?php header("Content-type: text/html"); ?>
at the top of the page but this doesn't solve the issue. Here is an example of the file headers that are downloaded when the issue occurs:
HTTP/1.1 200 OK
Date: Sun, 12 Dec 2010 23:42:18 GMT
Server: Apache
X-Powered-By: PHP/5.2.14
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html
Here is an example of the headers when it loads correctly:
HTTP/1.1 200 OK
Date: Mon, 13 Dec 2010 03:04:08 GMT
Server: Apache
X-Powered-By: PHP/5.2.14
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Encoding: gzip
Vary: Accept-Encoding
Keep-Alive: timeout=10, max=28
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html
I found the issue was being caused by my css and javascript minifier script, "CSS and Javascript Combinator". When I swapped it out to use "Minify" the issue was resolved.
Does the header header("Content-disposition: inline"); help?
You need to tell apache its OK to use SSL with php files.
Have you got the correct stanza in the extra/httpd-ssl.conf
It should look something like:-
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>

Categories