Support

Admin Tools

#27512 ^M characters in nginx.conf are causing nginx.conf to

Posted in ‘Admin Tools for Joomla! 4 & 5’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
n/a
PHP version
n/a
Admin Tools version
n/a

Latest post by moomoochoo on Tuesday, 11 April 2017 23:10 CDT

moomoochoo
Hi,
I used the nginx configuration maker to create an nginx.conf file. It's great, but contains
^M
at the end of each line which causes errors on my linux server when
I reboot nginx. This is more of an inconvenience than a problem as I can remove the characters myself, but I thought I'd let you know just in case you were not aware of it. I couldn't find any mention of it in the docs or other tickets.
Cheers

nicholas
Akeeba Staff
Manager
That's strange. I could imagine why this could happen (I used a Windows computer to build the package) but I did check and the files used to generate the NginX configuration file don't have CRLF endings. Is it possible that you used FTP to upload the files or have enabled Joomla's FTP mode prior to installing or updating Admin Tools? That could cause some servers to transfer the files in ASCII mode which does indeed change the line endings on transport.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

moomoochoo
That could have been possible, so I double checked by deleting the file then recreated it using the config maker. The CRLF endings were present in the new nginx.conf file.
FTP settings weren't enabled at any time. Not sure if this has any relevance, but I've been using vim to view the file.

nicholas
Akeeba Staff
Manager
What I meant is that if you installed Admin Tools using FTP then the administrator/components/com_admintools/Model/NginXConfMaker.php file will have CRLF line endings instead of LF. Why does that matter? Let's see some points.

In that file there are the literal string blocks which get concatenated into the nginx.conf file. Therefore, if that file has CRLF line endings you get CRLF line endings in your nginx.conf (and that's the only way it can happen). So, the problem we have to deal with is that administrator/components/com_admintools/Model/NginXConfMaker.php has CRLF endings.

I know I built the installation package on my Windows computer. I checked my computer and I see that the file has LF endings. So it couldn't have been a problem in the package.

Which leaves us wondering, why a file with LF endings ends up having CRLF endings? The only reason I can think of is that it's transferred over FTP in ASCII mode. This can happen either manually (e.g. restoring a backup where you transfer the files over FTP in AUTO mode, not FTP in Binary mode or SFTP which is always a binary transfer) or you have Joomla's FTP mode enabled. In both cases the files could end up having their line endings converted to CRLF.

If, however, only parts of the file have a CRLF ending the problem would be user input in the NginX Conf Maker page. If I recall correctly submitting text in a textarea from a browser running under Windows generates CRLF line endings. Therefore as soon as you save anything in the NginX Conf Maker page from a Windows computer you'd end up with some bits having CRLF endings.

I want your help to understand which of these two scenarios (FTP or using a Windows computer to save the settings) is most likely to have happened so I can figure out how to reproduce it and see if I can do something about it :)

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

nicholas
Akeeba Staff
Manager
While typing this I thought that there might be an easy way to work around it. Can you please the latest dev release a try?

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

moomoochoo
Sorry for the delay. I was using a windows computer when I saved the settings.
After installing Admin Tools Professional (dev) revE637933 I generated a new nginx.conf file. Everything looks great! No CRLF characters to be seen anywhere :)

Regarding my installation
Admin Tools was uploaded via browser from a windows machine via the administrative backend- Extensions->Manage->Install-> Upload Package File.
On the server, I checked administrator/components/com_admintools/Model/NginXConfMaker.php it didn't contain any CRLF characters.

nicholas
Akeeba Staff
Manager
OK, then it's exactly what I thought: Windows browsers send CRLF when submitting multiline textarea fields. This is something I had seen before, once, only when I was doing some development. I thought that maybe I was doing something funky but, hey, at least it's not just me and now it's fixed!

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

moomoochoo
Excellent! Thanks Nicholas :)

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!