Web Server on independent Jail

xames

Patron
Joined
Jun 1, 2020
Messages
235
Is out there any type of jail to run some web pages server over internet?

Thanks.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
  • Create jail
  • iocage console <jailname>
  • pkg install nginx
  • sysrc nginx_enable=YES
  • service nginx start
Voila! Web server!

What precisely is your problem?
 

xames

Patron
Joined
Jun 1, 2020
Messages
235
mmm ok, i try out and see the configuration how it works. Many thanks.
 

xames

Patron
Joined
Jun 1, 2020
Messages
235
Any tutorial out there how to configure step by step nginx on TrueNas after that commands? Commands work fine but now, blank page, how i transfer files inside this jail, how to secure the web, etc...
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
The Nginx webserver inside your jail is really no different from an Nginx webserver on any standard FreeBSD host. So, no, there is no TrueNAS specific documentation. You are essentially running a FreeBSD "VM" on your TrueNAS.

If you would describe what you want to achieve in the end, there would be a higher probability of qualified help.

For example:
  • you can enable SSH in your jail, set a root password (or create additional users) and use SSH to login and to transfer files
  • you could map ("mount" as it is called) an existing share on your NAS into that jail so that Nginx may serve the content as web pages
  • you could - the other way round - create a share from some directory inside your jail, so you could access that via e.g. SMB
As for hardening - there's the Nginx documentation for that. This really - and I definitely don't want to be condescending - is completely out of the scope of TrueNAS. You want to run a web server? Congrats! You are a web server administrator, now. There is really nothing TrueNAS can do here. Although most regulars on this forum including me do indeed have quite some expertise in running other web applications.

So, please try to describe your use case in as much detail as possible. I will try to help as best as I can.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
Perhaps what would be helpful is to say that the default pkg install of nginx puts the http root in /usr/local/www/nginx inside the jail and the config in /usr/local/etc/nginx/nginx.conf

If your pool was named tank and your jail named nginx, you could find those files on your host system in:

/mnt/tank/iocage/jails/nginx/root/usr/local/etc/nginx/nginx.conf

and

/mnt/tank/iocage/jails/nginx/root/usr/loca/www/nginx

Maybe that's enough, but if you need material on how to configure nginx, maybe best to go to the source directly:

You can skip past the setting up and starting sections as you should already have that part complete.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Or, if you want something a bit simpler to configure, there's always Caddy. These instructions focus on its use as a reverse proxy, but it's a general-purpose web server that can do pretty much anything nginx can do:

But though the configuration file is much simpler, once you install it, you're now a web server administrator, and it'd be pretty much up to you to configure it to do whatever you wanted it to do.
 

xames

Patron
Joined
Jun 1, 2020
Messages
235
I work simple nginx internal web server without proxy, now i will try danb35 script, when i try with root shell on truenas and try to execute script says:

truenas% ./caddy-jail.sh
-sh: ./caddy-jail.sh: Permission denied
 

xames

Patron
Joined
Jun 1, 2020
Messages
235
I have installed and change Caddyfile with basic default NO TLS configuration, but the page is blank, my html page have the index.html as first page.... which page is trying to load?

Thanks.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
when i try with root shell on truenas
You should not be doing this in a root shell on TruNAS, you should be running this in a jail.
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
You should not be doing this in a root shell on TruNAS
Yes, you should. The script creates the jail and installs the relevant software.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
My mistake, carry on.......
 

xames

Patron
Joined
Jun 1, 2020
Messages
235
Fine with Dns cloudflare, but now i have a page inside my webpage on php that is not working... how to make it work on caddy the php page?

And why when someone visit page show to accept to go there with this certificate.... i don't want that for visitors. Thanks.
 
Last edited:
Top