Fix “HTTP Error 413 Request entity too large” problem

Yesterday Jeff Madsen has sent a small Laravel tip which address how you can validate the post size for your uploaded data via Laravel middleware called VerifyPostSize.

Even though the solution is valid when you have no control over your server, but when you do, you should fix the base of the problem which is your web server (in my case its Nginx ).

Normal when you upload a file, the process looks like this :

webservers

1- The user request the website

2- The Server get the request first and forward it to PHP process.

3- PHP process do the magic and response back to the Server.

and the data get back from 3 to 1 .

Now as I said the solution which was provided solve the problem at the PHP processes level not at the Web server, at the end the data need to go throw the server first.

In nginx documentation we have a core module which control the size of the data which the client can send throw the server, the default size is 1Mb, so to fix this problem you need to do the following:

1- edit the file /etc/nginx/nginx.conf and make sure that  the value for client_max_body_size is big enough like:

2- edit your php.ini file to make sure that you have setup the upload size and memory with big values like :

last then you need to restart nginx.

now just a small note, you will need to adjust the values based on your needs, there are no magic values which can solve your issue here.

If you find that this information is incorrect, please let me know via email z[At]zah.me or via contact page I’ll be happy to get more information about this topics from experienced people out there.

PS: as usual, since english is not my mother language, you might find some errors, so if you do let me know and I will be happy to fix it.

The typical image of the Syrian Refugee

Note : am not saying that some of the countries didn’t help the Syrian refugees, all am trying to show that the media is only showing you what they think as a selling headline for them.

Five years has passed since everything has started, many Syrians has left their country running away from the death and the war, and yet the only image you see everywhere is the suffer and the dead bodies. am not saying that those are not real, we have people living every single situation you can imagine from the best situation to the worst situation.

My main point in this post to tell you that they are trying to hide the other part of the situation, the one which talk about how some Syrians has started their own business again ( check this article -Published at July 2015 ) , the one which talk about how Syrians has supported the economic of the countries which they are living within right now, either by work force or by money.

recent study ( Published at March 2016 ) talk about the impact of the Syrian businesses in Turkey , and am quoting the following :

The paid-in capital of the 4,000 or so Syrian firms in Turkey amounted to around $220 million in 2015. This amount excludes informal firms and funds invested directly into the economy via real estate deals, business transactions using front companies, etc. According to the Syria Trade Office, a consultancy in Mersin, at least $10 billion of Syrian money has flowed into Turkey since 2011, mostly to its southern provinces. This may seem small in the context of an $800 billion economy, but the impact in provinces nearer to Syria and on Syrian businesses in larger cities like Istanbul’s “Little Syria” is significant.

Even in Saudi Arabia, and sadly there are no formal study nor they have any immigration law, the market has been supported with work force, and for cheap salary.

Most of the countries near Syria does not have immigration law, and when they talk about the refugee numbers they will include all the Syrians who come and stay in the country even if they are living on their own without any financial support from the country, and many times also without any legal support, so they will work under the radar cause they have no work permit: for example , quoting from the same study :

While Syrian firms range widely, they tend to concentrate in the restaurant, construction, trade, textile, real estate, travel, transportation, and foodstuffs industries employing a portion of the 400,000 Syrians working informally.

Some countries are now trying to fix this, as in Turkey since they stated that they will provide the Syrians with work permit which will help to make things much better for the Syrians and protect them, but also this will help the country too, as it will force all the companies to register any Syrian worker and pay the taxes/insurance which the law require. Also I read that Jordan is started to do something similar, but am not 100% sure about that.

Am not sure if you know that, but in the factory near you (or any work place), you might be able to find an engineer or a doctor who is working as normal worker behind the machine because he has no prove about his education, yet he can speak many languages, there is nothing wrong in his work, at least he is not begging for money, instead he is doing his best to live a decent live.

The bottom line of what I want to say, is this: The media is going to tell you that those are going to steal the job from you, they are going to steal money from you, they want to kill you, but they wont tell you that  those are people who lost everything and they are trying to start again, they wont tell you that those are going to help you build the country they live within and support the economy by paying taxes and produce more work or opportunities for others to work with them.

I will always be grateful to any human being who helped and still trying to help those who in need.

If you find any issue in my language just let me know via the contact page and I will fix it, as the english is my second language, and am sure there are many grammatical mistakes which need to be fixed.

Redirecting to another port using iptables

One of the things that I hate about nodejs is that I will have to run it as root if I want to use the port 80, but yesterday while I was reviewing a book called Mastering Web Application Development with Express and one of the solutions which he talked about so that you dont need to use the root user is to redirect the ports using iptable , so this is what you have to do :

remember to change eth0 to the one you are connecting to, in my vagrant it was eth1

And since iptable does not save anything as permanent, you have to do small work (read more about it here)

And we are done, no need to use the root account any more 😉

We should not ship shit

Not sure why but many companies and startups only try to work and ship shit to the cloud. So everyone out there be ready and check this nice video from Uncle Bob Martine about Professionalism in Software and that we should demand that every software developer should care about it.

 

Some notes about Installing Parse-Server

 

Ok here is what I have found from installing Parse Server (just to read the code, or at least try to) on a fresh ubuntu 14.04

  1. You need to install nodejs ( WHAT ).
  2. You need to make sure that you have the following packages : g++, make , python, gcc.
  3. You need to install this library which I have node idea what is used for : sudo apt-get install libkrb5-dev

Then you are ready to go.

have fun.

 

© 2016 Zaher Blog

Theme by Anders NorenUp ↑

%d bloggers like this: