My django website sometimes cannot open images and the error message is:
"Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH"
However, when I open the link next to the error message on a new tab, the image is loading. I am using Apache, not nginx.
Here's how image looks like when I tried to open on a new window
As you can see it's not fully loaded!
Could someone help me with this problem?
Finally, I was able to fix it. Of course it was an apache problem. First I have activated my sudo a2enmod expires then added ExpiresDefault "access plus 1 month" to my media and static Directory in mysite.conf file.
Related
Folder structure as below:
|-root
|-pages
|-_app.tsx
|-index.tsx
|-public
|-logo.svg
|-image.png
|-image2.png
|-image3.png
When I run yarn build and yarn start in localhost, my image files can be found in the following locations:
Everything works fine if I deploy it via Vercel. However, when I tried to deploy on AWS(ECR image), only SVG files were found. Error showing
Failed to load resource: the server responded with a status of 400 ()
Also it shows "url" parameter is required when I click those image URL.
Could you please let me know what the issue is?
Edit: PNG files aren't created when deployed to AWS
I eventually found out that it was a configuration issue with Nginx.
As Nextjs Image component will send the image source path with the size through url query string, so
Accept parameters must be set for Nginx
location ~* ^/(.*) {
proxy_pass http://service_url/$1$is_args$args;
}
How can query string parameters be forwarded through a proxy_pass with nginx?
Make sure cloudfront behavior not to ignore the query string
https://github.com/vercel/next.js/issues/25121
I am trying to run django on XAMPP Apache server and followed the steps mentioned here. Here are the changes in Apache config:[![enter image description here][1]][1]
When access the application in browser below is the result instead of django page:
[![enter image description here][2]][2]
Please help what I am missing in this ?
#Razenstein: Following are errors in Apache log:
AH02102: C:/xampp/htdocs/polls/mysite/mysite/wsgi.py is not executable; ensure interpreted scripts have "#!" or "'!" first line (9)Bad file descriptor: [client 127.0.0.1:58357] AH01222: don't know how to spawn child process: C:/xampp/htdocs/polls/mysite/mysite/wsgi.py
The application is running fine with built in python server. After correcting Alias getting "500 | Internal Server Error"
[1]: https://i.stack.imgur.com/w2R0Y.png
[2]: https://i.stack.imgur.com/vl8Da.png
ok, this error message says that Apache tries to execute wsgi.py as a cgi script and not as python. A possible reason is, that you tried to deploy your app on Apache with some wrong commands that are still in the httpd.conf or vhosts-httpd.conf. This typically happens if you follow one (bad?) tutorial without success, switch to another one and forgot to clean the the code from the first trial (only a guess!). There is all kinds of strange turorials out there and sometimes it is also difficult to understand if they are for Windows or Unix.
Something like the follwing would cause that behavior:
Alias / C:/xampp/htdocs/polls/mysite/mysite/wsgi.py
<Directory C:/xampp/htdocs/polls/mysite/mysite>
Options +ExecCGI
AddHandler cgi-script .cgi .pl .asp .py
Require all granted
</Directory>
please search in your httpd.conf and vhosts-httpd.conf if you have left something similar.
your "WSGIScriptAlias ...." is overwritten by that and not active.
I have configured my subdomain on route53 to point to my ec2 public IP, right after I did this I got a welcome to nginx page. It was good this far. Now I add a custom cofig file in nginx/sites-available(also did link it to sites-enabled and also reloaded nginx). I don't see anything new. I still see the same welcome page. I wonder why this happened.I also have proxy_pass to :3000 which doesn't seem to work.
Here are the few things I tried and the result I got.
changed index.html file as mentioned in the root(/usr/share/nginx/html) - Still welcome page
tried server_name with both default_server and my subdomain(http://management.teampapercloud.in) - Still welcome page
stopped nginx service with service nginx stop - Surprisingly it still shows welcome page.
tried sudo lsof -i :80 (when nginx is running it has 2 diff nginx processed running one with root as user and the other www-data), when nginx is not running sudo lsof -i :80 gives nothing.
at this point i wondered if the domain hitting the server at all or not. I tried to ping, got my ec2 ip. tried DNS checker got my ec2 ip.
Now I am so frustrated stopped my ec2 instance. Now the welcome page is gone. which means I believe my ec2 instance is doing something to show the page, But I don't know which service.
checked top and service --status-all | grep + I don't see any strange services running nor services like Apache. as apache is not installed at all.
As a final try, I even uninstalled nginx. - I still see the same welcome page.
Updated all the index.html files I could find - Still same welcome page.
At this point, I am left with no ideas, and don't understand what is happening. Help is much appreciated.
Thanks
You have written, you reloaded nginx, try again (sometimes we forget to check common things):
sudo service nginx -t # check if configuration syntax is ok
sudo service nginx reload #reload configuration
sudo service nginx restart # restart server
Another important thing, check realtime log in terminal
error log: tail -f /var/log/nginx/error.log
access log: tail -f /var/log/nginx/access.log
and visit the page from browser and check the log in terminal.
Note: Log files can be in different directory in your server.
check log files with this: ls /var/log/nginx/
May be restart the os, if you have access to restart.
ec2 can have any page cache settings.
Are you using something cloudflare name server that can cache a
page, or, Any proxy server or something, that can cache the page.
You can even try browser incognito window, force reload in browser
(ctrl + shift + R).
The changes are not being applied because you're not making any changes to root directory which is
/var/www/html$
as this is a default public folder for your web server. Also if you wish you can change this default path to the one you want.
As you can see I have "index.nginx-debian.html" which on changing takes effect immediately.
When something goes wrong the server returns the default nginx 502 Server Error, I'd like to show my own server error page.
I put 502.html file to the template directory but it doesn't seem to work. It works for 404.html so I am sure I put it to the right directory.
Any ideas how to solve this problem or what could I miss?
Since 502 means "Bad Gateway", Django (or even the WSGI server in between) is not aware of the request at all. You can add a line similar to the following to your NginX configuration file:
error_page 502 /var/www/502.html;
My WAMP server started giving 403 Forbidden error after I installed Zend framework. Before that everything was working ok.
I have allready edited:
#onlineoffline tag - don't remove
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
to
#onlineoffline tag - don't remove
Order allow, deny
Allow from all
and put the server online
if I remember correctly at least one of the Zend installs comes with an Apache and MySQL which it installs as well as the framework.
Are you sure you have not got wampapache the WAMP apache service name, and Apache the standard apache service name both running?
EDIT
To view services:
Press windows key + R
enter services.msc into the dialog that launches.