You will need several programs that are not shipped with FreeBSD. Run the following command to install them:<\/p>\n
pkg install nano wget git mercurial bzr\r\n<\/code><\/pre>\nDownload and Install Golang<\/h3>\n
Download golang by running the following set of commands:<\/p>\n
cd \/tmp\r\nwget https:\/\/storage.googleapis.com\/golang\/go1.3.3.freebsd-amd64.tar.gz\r\ntar -C \/usr\/local -xzf go1.3.3.freebsd-amd64.tar.gz\r\n<\/code><\/pre>\nSetup Environment Variables<\/h3>\n
Create a variable called\u00a0GOPATH<\/code>\u00a0(which will be the location for installed packages) and add it to your path:<\/p>\nmkdir ~\/.gopkg\r\nsetenv GOPATH \/root\/.gopkg\r\nset path = ($path \/usr\/local\/go\/bin \/root\/.gopkg\/bin)\r\n<\/code><\/pre>\nIf you want to have the path set on boot, then run the following command to add it to your\u00a0.cshrc<\/code>:<\/p>\necho \"setenv GOPATH \/root\/.gopkg\" >> ~\/.cshrc\r\necho \"set path = ($path \/usr\/local\/go\/bin \/root\/.gopkg\/bin)\" >> ~\/.cshrc\r\n<\/code><\/pre>\nVerify Installation<\/h3>\n
Run\u00a0go<\/code>\u00a0in your terminal. If you are presented with a list of options, then the installation was successful. Run the following command to install a web framework called\u00a0Martini<\/code>:<\/p>\ngo get github.com\/go-martini\/martini\r\n<\/code><\/pre>\nIf you don’t see any errors, then you may proceed to the next step.<\/p>\n
Setup Martini<\/h3>\n
Create a file called\u00a0server.go<\/code>\u00a0and populate it with the following lines of code:<\/p>\npackage main\r\n\r\nimport \"github.com\/go-martini\/martini\"\r\n\r\nfunc main() {\r\n m := martini.Classic()\r\n m.Get(\"\/\", func() string {\r\n return \"Hello from AKLWEB Host VPS :)!\"\r\n })\r\n m.Run()\r\n}\r\n<\/code><\/pre>\nWhen done, save and run\u00a0go run server.go<\/code>. Provided that you do not see any errors on your terminal, then you can proceed to the next step.<\/p>\nSetup Nginx Reverse Proxy<\/h3>\n
Configure Nginx to reverse proxy to the Martini server. In\u00a0\/usr\/local\/etc\/nginx\/nginx.conf<\/code>\u00a0look for\u00a0location<\/code>\u00a0and replace its content within the curly brackets with the following:<\/p>\nexpires 8d;\r\nproxy_set_header X-Real-IP $remote_addr;\r\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\r\nproxy_set_header X-Forwarded-Proto $scheme;\r\nproxy_set_header Host $http_host;\r\nproxy_set_header X-NginX-Proxy true;\r\nproxy_read_timeout 5m;\r\nproxy_connect_timeout 5m;\r\n\r\nproxy_cache_key sfs$request_uri$scheme;\r\nproxy_pass http:\/\/127.0.0.1:3000;\r\nproxy_redirect off;\r\n<\/code><\/pre>\nOne you have added that, save and run\u00a0service nginx restart<\/code>\u00a0or\u00a0service nginx onerestart<\/code>, then run\u00a0go run server.go<\/code>. In your browser, enter\u00a0http:\/\/0.0.0.0<\/code>\u00a0(change the IP accordingly) and you will see a page that says:<\/p>\nHello from AKLWEB Host VPS :)!\r\n<\/code><\/pre>\nCongratulations, you have successfully setup an Nginx reverse proxy server with Golang + Martini.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"","format":"standard","manualknowledgebasecat":[109,230],"manual_kb_tag":[434],"_links":{"self":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2856"}],"collection":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb"}],"about":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/types\/manual_kb"}],"author":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/comments?post=2856"}],"version-history":[{"count":2,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2856\/revisions"}],"predecessor-version":[{"id":2863,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb\/2856\/revisions\/2863"}],"wp:attachment":[{"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/media?parent=2856"}],"wp:term":[{"taxonomy":"manualknowledgebasecat","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manualknowledgebasecat?post=2856"},{"taxonomy":"manual_kb_tag","embeddable":true,"href":"https:\/\/support.aklwebhost.com\/wp-json\/wp\/v2\/manual_kb_tag?post=2856"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}