Install web server( nginx on FreeBSD,pfsense) and add nat,rule in pfsense to access from out side

Prerequisites

  • FreeBSD 10.2 with IP Address : 192.168.1.110
  • Root privileges

Step 1 - Update system

To get started with installation, log in to your freebsd server with SSH/Console. And make sure your system is up to date, you can use command below to update your system : 

#freebsd-update fetch
#freebsd-update install


 And please install nano editor to complete the preparation with pkg command :

#pkg install nano

Step 2 - Install Nginx

 Before you start nginx installation, you can search the packages and nginx version with "pkg search" command, this is example :
pkg search nginx
nginx-1.8.0_3,2
nginx-devel-1.9.2_2
and you will get all two version of nginx, and in this tutorial we will install stable version 1.8.
Now begin installing nginx with the following command :

#pkg install nginx-1.8.0_3,2

Step 3 - Configure Nginx

 please rename a file "nginx.conf" to other filename to make it as backup.
#cp /usr/local/etc/nginx/nginx.conf /usr/local/etc/nginx/.conf.original

#nano /usr/local/etc/nginx/nginx.conf
make edit port 80 to num-port you want:

server {
listen       80;
server_name  localhost;


Save and exit.

#nano /usr/local/www/nginx/index.html
edit html code with default nginx page

Once that is complete, add nginx to the system of startup script "/etc/rc.conf" file. You can add nginx with nano editor or "echo" command as manual method, but here we will use "sysrq" command to do it :

#sysrc nginx_enable=yes  or add edit:

#nano vi /etc/rc.conf
add this line: nginx_enable="yes"

Before you start nginx, make sure the configuration is correct with this command :
#nginx -t

now you start nginx :
#service nginx start
Just open in the browser your server IP : 192.168.1.100:port_num

if you want to access from public ip we use nat
pfsense how to NAT 
=============
http://linoxide.com/linux-how-to/install-configure-femp-stack/