/usr/local/www files get corrupted

Hi FreeBSD forums,
This weekend I decided to spin up an Nginx server on FreeBSD to get more comfortable with the system. However, I have an issue, every file in the /usr/local/www directory, including it's subdirectories become gibberish.

Here is a sample:
Code:
»¨<úåº,uIO6SjxÜH+!D˜ffqBÓŠ·|eÏ’B¶ñ hújÁ™TðT„ >ÃMß|üº ×n )ðwѹÍKèÙ¡yv‹üž/tï(L˨˜êÖÙ0e&”ï߇H_¦@~Gü±óÐ_ùz—t}Óa›]Q&%›AÚ’¿cÜçÆéÃæwF1Oô*<ÖÇα†J˜E@œ](^©¨)Ös„ŒÐPUw/ȵWýÒr¿æá<+WÒ¯ø(SÖx¢û´Ô·;Õú]͸*“Š&ëˆÑÈ3¡¹5õ†P³:‡ÓÖú•“†QTX« ,¦ÑPcDù,ï ]‘ß…·¸mÑÍݼ¸_ÄÓëjGÍò6$_°6ncݺ<Vø{n†ÓšÒ÷,nª.&0D†£´÷è7<¥•‡Þ°*¼-èÕ𦓩ÐÊâ,ѯáþÛ änO„¯U2Ry±T#¯Þé[&I¼’vL¹½º ˜†jÔ³´=4d,(ÓGäÖo”þ;Ñ dó»m´ÝÆ di,,®ìÖºä4£U^"Æ:äqayIƒ®ôÝ£=jB¿2>’–ú{%£ „"Ê"¾@ï¦#ÕM¿c¢Ãòãšk›þ<»RpªP‘Mj~knúwbC“9d>òàG´aŠP„Vic›:k£ãb‚Z4kOAÅLÐSDluq½JriMèQKT%'¤•Ž A¼§v[É‘xþ©lœîNï¸,ž–FÉkYB\EV»°üÉ >h¾Oçzëz2 ³^Æ€”ª˜ÂKxb§„ §'e#þpÂt/0¸xÒE‹©ò¶’° »ùqüžTTñà ETæ•!L–Q.q]§húóì,ÏâHwS§ºvÈî6ÿ5$;½x³·°QlrÎMûÁ²Ä€ÒÒà0ì…ºÇT˜þmfªE¹â„çѬS¶1×’úãÜPî&ÔNîî ÈC;|z¼îxct @¿)‘Ã%Ô!È9΋÷«æßDÖ[vyE8(1+ß>Aas$šÜf«žÌÀQðB‘ׇž&gû:q™±9ï¹Ô& B!³4óT÷ìwQW×›;ÇvBÈø‰NOn}–fx4°PŠÆ–3¦ƒéYyÞó6€¬€ƒ?b7¶Ì]¶œ¢ÃÊL§$Ž™—zdÙAÌí.Å[8ˆù7b¡OêÆû#Q÷X[©þaFCÇ1èóëç ˜ø]$øUtÀNô˜W\×(0Ën‰=fñ’—L<} ô—=Öó+O«ÆšxU^W,.¹?RNÆá\&OoåI\òꪚ;B6EørŒKßL4{ŽŽRÖb˜°ž’¨yEè@«Õ÷œgô»½]“ÉÖ×Ç›, …?\½+n``hÎO@›ÔÅ §¬wÒ¾hT~:°þ€†u†?£¿]/„71Bû = s!öÈk¬öÝ›r

Help is very much appreciated. I run FreeBSD14.1-RELEASE-p5
 
That’s not at all normal; could be hardware.

VM or bare metal?
it's running in a vm
It's perl code :)

Anyway, please describe the system this is running on.
Uninstalling perl fixed it, thanks a lot! I installed it by accident.
Nevermind, it didn't get fixed.
I run FreeBSD inside a KVM and I use UFS. I looked for any trace for perl on my system and removed it, but I still get the same issue. I didn't install nginx with perl.
The website files are in a user's home directory, maybe that's the issue, since I setup a default vhost serving the default nginx files and it works flawlessly.
 
The website files are in a user's home directory, maybe that's the issue, since I setup a default vhost serving the default nginx files and it works flawlessly.
FreeBSD or nginx or UFS aren’t going to trash your files like this, so possibly something to do with the VM, or how it is running - for example are you starting it up and shutting down cleanly?

The whole Perl thing was a joke, but what you are seeing isn’t remotely normal for a FreeBSD system (or any OS for that matter).

Is the website exposed to the internet?
 
Sorry about the perl thing. Couldn't resist.
It's fine
Hm, looks like mis-configured charsets. No sure actually so.
that unfortunately applies also to when I `cat` or copy the files
Code:
cat index.html
t]▒▒Z#▒▒▒K!S▒ȜYղ▒R▒O▒▒▒▒▒V
                          ▒J▒▒▒▒)II▒▒:TJ▒6c▒▒▒R▒x▒▒Vt▒B▒m>▒▒r׺▒▒▒       j50銼▒▒+        ▒#▒wv▒▒▒▒,N׬▒▒QzJ7▒<'Z@ͭ▒j▒ɡQp▒e▒▒▒Q<▒▒[CH▒C▒絡B▒<▒▒▒▒1▒▒1\▒<▒▒�▒g▒m0▒ΐ▒▒#▒3H▒▒▒▒b▒▒>2▒u▒W▒m▒▒▒W▒▒:▒n▒璳W▒▒pc▒ ▒▒-▒▒▒͜J▒b▒mx▒c4▒▒!r▒▒▒]▒Q▒7|▒n▒▒▒▒▒▒u▒▒▒▒▒▒o▒▒▒▒l▒V▒▒▒▒&▒▒▒▒e▒
▒▒5G▒៩▒U▒`]▒▒(lO▒▒E'▒▒o|▒h8u▒▒r{QZ▒l▒▒▒`▒Y▒▒▒▒E▒e▒3▒▒▒'▒ɺL6▒NA윖؜
V▒;.▒eA蠼▒r(▒▒a▒Z▒q▒▒Ƶ▒▒▒w*L-▒▒%▒Lw▒▒ud▒▒▒h
I4▒p(▒0;KLN▒▒]▒"8.,▒m▒▒▒▒(\▒▒@▒▒▒r▒ڱ]▒LC▒▒▒w$▒B▒▒▒\S▒C6J▒▒▒9d▒֪▒.▒\;zD▒tH▒▒▒▒s▒t▒▒$4▒}▒A▒▒▒I▒▒q▒_Q▒w▒▒O▒\:▒▒▒▒ފ`▒=▒▒A/!▒S-▒▒b-,6▒▒▒▒m+v▒7▒.
P▒▒0(▒"Y.▒
▒▒n▒▒▒%▒▒▒
          |ۛ▒ł6&'▒       4▒v"p▒gAJ▒▒u98▒A!▒▒▒▒u▒ka▒▒}▒▒▒�▒▒>b▒b▒aOZY▒T▒Jѧ▒֐▒▒BKL▒7?r▒k▒▒▒sWl▒▒▒w▒▒▒▒b
▒▒ɲ▒c▒▒▒v▒*k▒▒▒▒▒
▒▒x>▒▒C?▒S▒X6Z▒▒▒z3▒▒▒▒V▒▒R▒▒X▒aZ▒▒▒▒▒[b▒▒D▒▒▒v▒:E▒_▒▒▒Ƥ▒▒▒;▒Wz▒▒7$g▒'▒Rq▒z`▒Rc▒<▒▒R▒ ▒▒▒O▒▒*▒▒fd▒a▒▒▒X▒▒N▒▒▒&▒L▒▒&i▒▒
@▒%nHa▒~▒v▒▒zϢ5e#|▒▒▒(F▒խZĂ▒1"▒+Ռ▒▒ʡ▒׵▒U]▒w7▒5;▒▒g
!Z▒▒▒▒y▒9l428W▒s▒1▒▒"[I▒▒5k▒Ī▒▒Y^
▒▒▒ڝ$**▒▒"▒<▒b▒dE▒)▒▒▒E='5z▒▒uh!▒▒!▒b*▒ȟf>t▒▒▒ڗk▒o▒▒▒\▒▒L▒a▒▒▒▒▒h▒>`▒H▒7▒▒Q▒▒5.▒▒<▒2▒▒▒▒X▒▒ ▒▒(▒▒▒▒^▒▒▒ɏX▒6▒    -씏eP▒▒=P▒F▒ ▒b▒▒▒hr▒   Ț|▒=�]o[(▒▒ֹ▒▒OA▒        ▒n▒
▒c▒?8▒퇊▒7▒▒▒EC|&▒,qK%▒P▒▒▒Y▒▒▒l▒)m3▒q6▒▒'fP<V9▒艹▒U▒▒▒;▒M▒▒v▒▒▒▒Ra▒▒?st▒o▒neB▒,hf▒R▒▒j▒N▒&▒▒▒3uM▒k▒▒▒▒ 瀂▒&    Zy▒$q%LR▒y▒▒▒▒▒ ▒>2%▒kaE▒▒C▒
                                                                                                                                            %▒▒▒▒▒▒▒▒W.▒5▒▒▒'R▒|▒▒xa▒▒>▒▒ئG▒▒▒▒Գ#p▒▒YZhly▒▒ϡ▒Z
b▒▒x}By▒P▒k_E▒ ▒@&▒tY▒7@▒▒츐r▒fz(▒▒*▒▒t▒▒▒}
▒▒▒▒ܧ/?=[O?▒▒$▒▒▒▒▒2▒▒;▒▒▒▒Hlo▒▒▒▒N▒¾ҹ▒19h▒▒f▒_▒▒▒/▒k▒$㲟▒▒/U▒l9ˏ▒▒▒M▒▒ԤMxl▒kh▒V▒▒▒▒ѸMR▒▒ ▒'+▒▒F▒xJT▒
)▒N▒:▒▒ڿ▒.x▒r   ▒P▒▒VD▒▒`мmG▒hE▒/▒▒;▒s▒h▒{▒▒1▒▒ڱW▒xt?▒)▒ww<W!_/:I▒▒f▒▒({▒~▒u!▒4▒▒َQ@.n▒▒▒XuӁ9H▒T▒▒▒▒▒▒@Ƽ/▒Yr▒]▒▒Tm▒,Y▒▒Hx▒O▒▒en▒▒▒▒▒W▒7q▒}▒-?I\/▒١▒▒p▒▒$z,▒R%;}g▒<1P<▒▒▒s▒.▒w▒▒m<ӗ▒▒8▒▒4ws5N▒'▒▒>▒▒▒▒▒▒^▒kI▒L▒Aƿ\湪▒▒C▒9▒l!▒▒▒▒Z▒$▒3
▒▒w▒  ▒!▒▒▒▒q0=r▒5ɹ▒+▒#L▒'▒▒
▒▒o޼▒▒f▒▒▒▒▒▒/ym▒▒▒▒▒/V/▒▒;▒g▒▒GF▒▒▒F▒TS9s▒=▒9▒▒l▒▒f▒▒Udg▒▒K
Something weird is that after I copy the files to the server and access them, the first time it works flawlessly, then the second time, it breaks. I think that's more of an nginx issue...
I will try using another http server like caddy.
 
What's your locale configurations?
What's the encoding of the problematic files?

If the both does not match, the file surely displayed "broken", unless you're viewing the file with something capable with auto encoding detections and conversion like misc/lv.

Otherwise, you need to convert the files to match your locale with iconv(1) or something alike, or switch your locale (it would be preferrable if the problematic files are in UTF-8 and your locale is not *.UTF-8).
 
Or your HTML files have unmatched charset attributes defined (or even not specified at all and your language configuration in your browser does not match the contents).
 
try
file index.html
Code:
# file index.html
index.html: HTML document, ASCII text, with very long lines (942), with CRLF, LF line terminators

Also, followup to my last post here, using apache for some reason fixes the problem. looks to be an nginx issue...
 
the first time it works flawlessly, then the second time, it breaks. I think that's more of an nginx issue
I would have thought that that if nginx corrupts files on disk by just one viewing then that would be a major issue that would have been addressed urgently.

Are the files www-writeable?
 
I decided to spin up an old computer I had around and try it on bare metal. This seems to be a fairly odd and isolated issue, since nginx serves the files just fine. I guess I'll reinstall FreeBSD on the VM and mark this as resolved.

Yup, reinstalling FreeBSD worked. Not sure why it didn't in the first place, but eh.

Thanks for the support.
 
Back
Top