Vasudev Kamath: Gzipped response for CSS/JS with Apache and mod_uwsgi
So it may sound normal to receive compressed response for CSS/JS file
from Apache2 but what I faced is completely different behavior, here I
saw not just body of response but also header are getting compressed
and send to browser and browser was unable to interpret the response
there by leading page rendered without CSS and JS.
That was long story short, so let me explain in detail the case and
what I found out.
I have hosted SILPA on my VPS using
uWSGI. I had used till date using libapache2-mod-proxy-uwsgi plugin
for which uWSGI should be using network socket and in Apache2 config I
need ProxyPass directive pointing to uwsgi://host:port and
everything used to work out of box. There is a drawback for using
network socket in uWSGI that is limited amount of ports (65535) and
possible clash with other services if we use wrong port number,
additionally network sockets will be slower compared to the file
socket so yesterday I thought of changing it to file socket and
removed socket directive in the ini file for uWSGI application
container for SILPA and here is where all problems started. My updated
configuration can be seen in our documentation page
that is if you are interested to look my configuration file :-).
Problem Reporting
We got selected to Gsoc again this year and we have lot of students
jumping in our channel #silpa on irc.freenode.net and yesterday
night some students reported they are facing 500 internal server
error and subsequently others mentioned there is no theme being
rendered. I checked and found everything was fine for me only to
notice that my browser was using cached content, and when I clear
cache there I go everything vanished, no theme no css no javascript
just plain html!!!.
Investigation
So I thought I should investigate this and fired up firebug on my
iceweasel to observe the network traffic. And below is what I observed
in firebug network console!.
So you can see no response header in the above image but there is a
response and below how is response content visible on firebug.
Still weird part was when using wget/curl directly to get the CSS I
was getting correct reply and the file, which is puzzling.
So I went ahead opened the CSS url directly using browser and saved
the resulting file. When I used file command on it, output
suggested the saved file in gzip compressed!. I went ahead
uncompressed it and opened the file and inside it I found response
header and the response body! So what just happened? Did apache some
how manage to compress entire respone not just response body?
The more puzzling question was why did it work when I was using
mod_proxy_uwsgi and failed when I switched to mod_uwsgi. I had no
clue at this point why this behavior is coming up.
So you can see no response header in the above image but there is a
response and below how is response content visible on firebug.
Still weird part was when using wget/curl directly to get the CSS I
was getting correct reply and the file, which is puzzling.
So I went ahead opened the CSS url directly using browser and saved
the resulting file. When I used file command on it, output
suggested the saved file in gzip compressed!. I went ahead
uncompressed it and opened the file and inside it I found response
header and the response body! So what just happened? Did apache some
how manage to compress entire respone not just response body?
The more puzzling question was why did it work when I was using
mod_proxy_uwsgi and failed when I switched to mod_uwsgi. I had no
clue at this point why this behavior is coming up.
Possible Solution
I was still not sure how to resolve this, and started searching in the
network but nothing was coming up in search result which can explain
me this. And finally I stumbled on a link which is totally unrelated but I saw the word mod_deflate in the
content and wandered on my system to see if its enabled. Yes
mod_deflate was enabled I just opened the conf file and saw
following.
Interesting so it suggests to compress css, javascript files etc. So I
thought possibly its compressing the result of mod_uwsgi, yeah possibly so
why not try disabling mod_deflate and check if it works well and
good if not I'm not gonna loose anything. So I disabled mod_deflate
and voila! Everything is working fine!
<IfModule mod_deflate.c>
# these are known to be safe with MSIE 6
AddOutputFilterByType DEFLATE text/html text/plain text/xml
# everything else may cause problems with MSIE 6
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
What might be the reason for this behavior?
Well I'm not exactly sure but here is my assumption. The whole
behavior depends on internal implementation of mod_uwsgi and
mod_proxy_uwsgi module. To confirm this I switched back to use
mod_proxy_uwsgi module and enabled mod_deflate and observed
request response in Firebug network console and below is what I
observed.
So response is still gziped but this time only response body was
gziped and Content-Encoding field was set properly which makes browser
to properly uncompress the response body and use it.
So it seems like there is a difference between mod_uwsgi and
mod_proxy_uwsgi implementation. mod_uwsgi was sending the response
along with response headers which was compressed by mod_deflate there
by rendering browser helpless to interpret the response. But
mod_proxy_uwsgi seems to be only sending the response content without
response body and this content was later compressed by mod_deflate and
proper response headers were set by apache before sending it to
browser.
So now whose fault is this? Is it the bug in mod_uwsgi or, mod_deflate
not being able to exclude response headers from compression? I've no
clue! If you have a clue and you want to share it with me, please
consider writing to me over email. My details are available in
Contacts
So response is still gziped but this time only response body was
gziped and Content-Encoding field was set properly which makes browser
to properly uncompress the response body and use it.
So it seems like there is a difference between mod_uwsgi and
mod_proxy_uwsgi implementation. mod_uwsgi was sending the response
along with response headers which was compressed by mod_deflate there
by rendering browser helpless to interpret the response. But
mod_proxy_uwsgi seems to be only sending the response content without
response body and this content was later compressed by mod_deflate and
proper response headers were set by apache before sending it to
browser.
So now whose fault is this? Is it the bug in mod_uwsgi or, mod_deflate
not being able to exclude response headers from compression? I've no
clue! If you have a clue and you want to share it with me, please
consider writing to me over email. My details are available in
Contacts
Thanks to bernat on #debian @ irc.debian.org for

Update on 2014-03-03: quoting Colin Watson from
Wow, today was pretty crazy in terms of the travel we managed to pack into one day.
This morning, Zoe woke up at about 5:30am and jumped into bed with me for a
snuggle and another half hour nap. After that we got up. Zoe had been eyeing
off the egg cups in the house, and so I'd wanted to do soft-boiled eggs for
breakfast. So we doused ourselves in mosquito repellent and raided the chicken
coop.
I don't think I've ever cooked soft-boiled eggs in my entire adult life, and
today wasn't an exception. They came out hard-boiled. Zoe still ate them anyway,
she just couldn't do the toast soldier thing. I need to buy some egg cups
for home and we can try again. I hear the Thermomix can do boiled eggs.
After breakfast and a shower, I got stuck into packing up and cleaning the
house, and Zoe watched TV. At 8am she turned off the TV and declared she wanted
to play in the yard. It was nice to see that she wanted to do something more
than just veg out in front of the TV, without prompting.
I had us all packed up by about 8:30am and we were only 5 minutes from where
the barge docked, so we drove over to the other end of the island to take a
look at the place at high tide. It was quite different from the two days before
in the afternoon at low tide. The stick that we'd walked out to was barely
above the waterline.
Then we drove back to wait in the queue for the barge. The barge journey back
was uneventful and we made it back home by 10am, which was about the
time I was expecting, and rendezvoused with my girlfriend, and did a fast
unpack and repack. We then headed to the airport, arriving comfortably with
enough time to check our luggage and get some lunch to take onto the plane.
Zoe was great for the flight down. She watched Brave on the in-flight
WiFi entertainment on my phone, and got to fit the whole movie in before we
landed, but this meant she skipped a nap.
By the time we got to Melbourne Airport, she was in the post-tired manic state,
but we weren't in any particular rush, so we had a very roundabout trip to
baggage claim, and then after we'd acquired some Myki cards, caught a taxi to
our accommodation in South Melbourne.
After we'd unpacked and settled in, and I'd gotten some supplies from the local
convenience store, we caught a tram into Bourke Street to go to Chinatown for
dinner, after checking out the view from the observation deck on the 28th
floor.
We found a great dumpling place, and Zoe really enjoyed the pork dumpling and
noodle soup that I ordered for her. She kept alternating between eating the
noodles with her training chopsticks and the broth with one of the big spoons.
She was getting really over-tired and over-stimulated by this point, so it was
quite a bit of cat-herding to get to Chinatown, and more so getting back to a
tram to come back.
We got home, Zoe had a quick shower and went to bed without a peep. Her room is
nice and dark, so I'm hoping that she'll have a bit of a sleep in tomorrow.
(Wishful thinking).
I'm really quite pleased with how smoothly today's travel went. Everything went
off without a hitch.
I was super sad to know that
The next step on this front will be the addition of path-based
searches, using the excellent Postgres
Following my
It seems that several people replied to the effect that they would pay people to take care of applying security updates, or even configuring adhoc things such as wikis, graphite, and MySQL.
Not enough people to rely upon, but perhaps there is scope for remote stuff being done in exchange for folding-money. (Of course some of those that replied are in foreign countries which makes receiving payment an annoyance, that's a separate problem though.)
Food for thought.
In the meantime I've settled into my use of 

I ve been issuing a lot of x.509 certs and OpenVPN user configurations lately, and I came across something that has reduced the complexity quite a bit. It seems that OpenVPN configuration files can now include data inline. So rather than generating and distributing the following for each user:
Yana from the Jitsi team with a table full of devices running different operating systems and browsers connecting to a JitMeet video conference. The demo also extended to the
Any Linux web server - big or small, running your preferred distribution - can run a JitMeet conference. Here it is running on a very small 
Valve have