How to setup a folder outside / behind document root?

Hi,

I’m trying to install an application that because of security, there is one folder (Uploads) that must be placed outside / behind document root.

I never done this in the past. So can someone please help me and tell me how can i do this?

When i login by FTP on my InterWorx domain account i see the following folders:

/.pki
/domain.com
/var

If i enter the /domain.com folder i then see:

/html
/iworx-backup

All the application files are installed inside the /html folder.

So my question is, where should i place the /Uploads folder?

Thanks

Hi nqservices

I think root folder confuses a lot of people

The hosting folder is /html (anything in this folder is live to the Internet)

The / root folder is not live, but can be used

The above assumes you have not changed the structure of the root for the siteworx account

So in your example, your hosting folder to use for website is /html

You could then setup a folder /uploads from / root, which is not accessable to Internet users browsing your website, whilst allowing for your upload code to place/store files in /upload folder

Whmcs and a lot of other websites use the above, but the folders are called differently

I hope that helps

Many thanks

John

Hi,

Thanks for your help… but im still confused.

Where exactly should i place the Uploads folder? The current path where my application is hosted is:

/chroot/home/xyzuser/domain.com/html/

Where should i place the Upload folder?

Note: The manual on my software says in the Upload folder section: “We recommend moving Upload folder to a non-public location outside/above your web root to prevent web based access.”

Thanks

Hi nqservices

Many thanks and it can be confusing

You would create your uploads folder in the root folder

If you FTP into the siteworx account, goto / folder (this is the root folder), where you see /var, /html etc and create new folder called /uploads

Your root path to this folder would be

/chroot/home/xyzuser/domain.com/uploads

Does that make more sense

I can post a pic tommorow if it helps better

Many thanks

John

Hi,

Thanks again for the help. I now understand better. So my FTP folder structure will be:

/chroot/home/xyzuser/domain.com/html/ >> Location of all the public application files

/chroot/home/xyzuser/domain.com/uploads/ >> Location of the upload folder

So on the end, at the /chroot/home/xyzuser/domain.com/ folder i will have 3 folders:

/html
/uploads
/iworx-backup

Is this correct?

Thanks

Hi nqservices

Yes, you are correct

The /html is the web root (website)

The /uploads would be outside of web root

Many thanks

John

Thanks for all your help. Now that i understand seems so simple…

Just one final question:

I have tested put the Uploads folder in 2 different locations and in both locations my script worked properly:

Location 1:
/chroot/home/xyzuser/domain.com/uploads/

Location 2:
/chroot/home/xyzuser/uploads/

What do you think is more secure and the best local?

Once again thanks!

Hi nqservices

Many thanks, glad you understand it better

You would use your location 1, as this is accessable by FTP client

Your location 2, whilst works as you expect, is not accessable by FTP and therefore restrictive to your siteworx account. It is not advisable to change permissions to allow your siteworx account access to this folder

Many thanks and I hope that helps a little

John

Hi,

Thanks again for your help.

Regarding location 1, on my InterWorx installation it’s accessible using the default FTP account created for the SiteWorx user. I have put there the Uploads folder using FileZilla FTP client.

But that is not important now, because i think im doing it wrong because i did not understand properly the manual.

I have contacted the software developer asking them about both the Locations 1 and 2 and where should i put the Upload folder and their response was exactly as i quote bellow:


We recommend putting the uploads directory above any publicly accessible directories. If you must put it within your doc root, you should block access to all files within it using a mod_rewrite or other rule specific to your web server.

So as you can see from their response i making this the wrong way. I must put the Upload folder Above any publicity directory. So can you help me understand this?

What should i do and where should i pout the Upload folder?

Once again thanks!

Hi Nqservices
What’s in a name!
If it helps you understand easier, the following are all the same folder, but called differently
docroot
doc root
document root
html
hosting root
host root
hostroot
public
public_html
web root
webroot
The above are all the same folder, the folder which you store your website files so the public can view your website.
your option 1 location (using root folder / ) is correct and is outside of pubic access.
Your siteworx client can see the root folder (/, /html, /iworx-backup and /uploads) using FTP client or filemanager once logged into their siteworx account
I hope it helps
Many thanks
John

[QUOTE=d2d4j;28819]
I hope it helps
Many thanks
John[/QUOTE]

Yes, it helps! So just to confirm:

Location 1:
/chroot/home/xyzuser/domain.com/uploads/

Location 2:
/chroot/home/xyzuser/uploads/

I should use Location 1, correct?

Thanks again.

Hi nqservices

Yes, location 1 is correct

Many thanks

John

[QUOTE=d2d4j;28823]Hi nqservices

Yes, location 1 is correct

Many thanks

John[/QUOTE]

Once again thanks for your help! I will put it in Location 1.

Thanks

Hi @d2d4j

I now need to install a different software that also requires to be installed “Behind Document Root” to be more secure.

The application is a project manager named Activecollab (but is not the latest version. Instead is an older v3 version).

Anyway, im reading the documentation but is one part that i still did not understand and maybe you can help me. You can read the section that says: “Install activeCollab Behind the Document Root” at:

https://help-classic.activecollab.com/books/self-hosted-edition/security.html

Can you help me on this? If yes, let’s take as example that i the final url of the installation to be: http://www.mydomain.com

If you can, please help me. What should i do?

Thanks

Hi Nqservices
many thanks, and you would FTP into your domain, at root level create the 2 required folders (/uploads and /thumbnails), upload your website, and run the install.
Then you add to the config/config.php to the following:
define(‘PUBLIC_HTML_AS_DOCUMENT_ROOT’, true);
save and you shuold be good.
Please note - as I do not use this software, and have not fully read the manual, only the provided section of the manual, there maybe other areas which require further changes.
So, using your example of mydomain.com, it would be:
FTP to mydomain.com
goto / folder (root folder, where you see /html and /iworx-backup)
create 2 folders called /uploads and /thumbnails, so should now show:
/html
/iworx-backup
/uploads
/thumbnails
upload your website to the /html folder
Run your website installer
Confirm website runs as expected. if so
edit your config.php (from folder /html/config) and add the above line shown, define(‘PUBLIC_HTML_AS_DOCUMENT_ROOT’, true) and then save
test website again to confirm all works as expected
If you then want to use https access, you need to edit your config.php, and change the following:
define(‘ROOT_URL’, ‘http://example.com/public_html’)
to
define(‘ROOT_URL’, ‘https://example.com/public_html’)
I hope that helps
Many thanks
John

Hi John,

Thanks again for the help. So from your response i see that is the same as the first installation i done on this thread.

I just have to put the uploads + thumbnails folders on root and the public files on the html folder.

What was confusing me when reading the documentation was this part:


Define a virtual host where the http://intranet is mapped as public folder of your activeCollab setup. You can do that like this:

<VirtualHost *>
ServerName intranet
DocumentRoot /Library/WebServer/Documents/intranet/public
</VirtualHost>

So i do not need to create any new virtual host or edit the current one?

Thanks

Hi nqservices

Yes, you are correct as the vhost file already exists, so this can be ignored

Many thanks

John