Setting up NGINX / Linux development environment with Vagrant and Chef (Solo) - linux

As a disclaimer I am rather new to Linux after recently moving the Microsoft .NET IIS stack
The problem: I am having difficulty provisioning a ready made environment to develop against using the following...
Vagrant
Chef
VirtualBox
Apt (cookbook)
Apache2 (cookbook)
The error I am receiving is (when hitting the hostname or IP of the virtual machine)
ERR_NAME_NOT_RESOLVED
There is a lot of code so, I will just post my vagrant file and role...
Vagrantfile
-----------------
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.network :forwarded_port, guest: 80, host: 4567
config.vm.host_name = "www.example.vm"
config.vm.provision "chef_solo" do |chef|
chef.cookbooks_path = "cookbooks"
end
end
vagrant-test-boc.rb
-----------------
# Name of the role should match the name of the file
name "vagrant-test-box"
# Run list function we mentioned earlier
run_list(
"recipe[apt]",
"recipe[apache2]"
)
Any suggestions, guidelines examples would be most welcome!
Thanks!
Additional Edit: I have been advised to look into setting up an NGINX server using similar techniques, would this be another question or would it be valid along this thread?
My main resources have been....
https://adamcod.es/2013/01/15/vagrant-is-easy-chef-is-hard-part2.html
https://docs.vagrantup.com/v2/provisioning/chef_solo.html

If I understand correctly, you're trying to access the server www.example.vm (on port 4567) from your host ?
If that's the case, then the issue is probably that you've not told your host that www.example.vm is really an alias to your own host (localhost). Otherwise your host has no way of knowing that it shouldn't do a dns lookup and attempt to send a request to this host over the internet.
On a Unix / OSX box, you can edit your /etc/hosts, where you can add your fake domain name to the localhost line, like so:
127.0.0.1 localhost www.example.vm
Hope this helps! ; )

Related

Change Hostname Vagrant

I've setup two vagrant VMs of ubuntu - one for slave and one for master.I frequently get confused after logging into the vagrant VM using vagrant ssh which machine I'm in. What do I call this green string in the screenshot and how do I change this this for both slave and master machines like ubuntuslave and ubuntumaster?
The string in green is of the format <username>#<hostname>. So in order to differentiate between your two servers, you need to change the hostname, to give you something like ubuntu#ubuntu-slave.
To do this, you need to add the hostname configuration option to your Vagrantfile:
Vagrant.configure("2") do |config|
config.vm.box = "precise32"
config.vm.hostname = "ubuntu-slave"
config.vm.network :private_network, ip: "192.168.0.10"
end
This, however, will only update your hostname after you recreate the VMs. If you aren't planning on doing this, you will also need to modify the hostname within Ubuntu itself.

Cannot access eclipse orion server from local machine using local IP

I have been given a centos server to lauch eclipse orion code editor. I installed eclipse orion as per the instruction on https://wiki.eclipse.org/Orion/How_Tos/Install_Orion_on_Localhost (steps for linux using jetty server). It works fine on centos browser. The centos os is running on 198.168.1.226. So that I can access the following urls on web browser of centos.
198.168.1.226:8080
localhost:8080
127.0.0.1:8080
0.0.0.0:8080
But when I tried to access the 198.168.1.226:8080 from other local machines on local network, that is not accessible. I searched the StackOverflow Questions like how to make jetty server accessible from LAN? and Unable to access jetty server with local IP address but both are useless for me. How can I fix this situation? Can I fix it editing the code on orion.ini file or need to deal with configuration file or something else?
I have also tried the orion for windows computer but it worked itself for accessing the orion system for any other computer in local network. But I am surprised to face it on centos using the jetty server for setting up eclipse-orion system .
First of all check that have you allowed specific port (8080) from eclispse.
add rule with that port no. in centos iptables as below:-
iptables -A INPUT -p tcp --dport 8080 (adjust according your port no.) -j ACCEPT

Vagrant port forwarding 80 to 8000 with Laravel Homestead

My Problem:
I can only access my sites through port 8000, but not 80, which makes me think it is not redirecting 80 to 8000 as it says it should be. I want to simply type local.kujif.com into my browser and it loads the site, which I read was port 80 by default. I am using curl to check it and it returns:
curl 'http://local.kujif.com'
curl: (7) Failed connect to local.kujif.com:80; No error
However if I add :8000 to the url then it works; it returns my index.php which simply prints 'test':
curl 'http://local.kujif.com:8000'
test
My Details:
I am using Laravel Homestead and Vagrant with Oracle VM VirtualBox.
In the Homestead.rb it has the port forwarding. I haven't edited it at all:
config.vm.network "forwarded_port", guest: 80, host: 8000
config.vm.network "forwarded_port", guest: 3306, host: 33060
config.vm.network "forwarded_port", guest: 5432, host: 54320
I also have Microsoft IIS installed for my work stuff. I obviously stop that service whenever I need vagrant to use the localhost.
"vagrant up" shows:
My Homestead.yaml file:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: /Users/Tyler/.ssh/id_rsa.pub
keys:
- /Users/Tyler/.ssh/id_rsa
folders:
- map: C:\DEV\Linux
to: /var/www/
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: local.kujif.com
to: /var/www/kujif
variables:
- key: APP_ENV
value: local
You should continue to use ports above 1024 since they are non-privileged ports, BUT if you do want you can run as port 80 on the Homestead VM, as long as you don't have anything holding on to that port on the host machine. Just tried it and it worked, with a few gotchas. First, you change that line in the .rb file from:
config.vm.network "forwarded_port", guest: 80, host: 8000
to
config.vm.network "forwarded_port", guest: 80, host: 80
When you fire your VM up after saving you will get a warning from vagrant:
==> default: You are trying to forward to privileged ports (ports <= 1024). Most
==> default: operating systems restrict this to only privileged process (typically
==> default: processes running as an administrative user). This is a warning in case
==> default: the port forwarding doesn't work. If any problems occur, please try a
==> default: port higher than 1024.
==> default: Forwarding ports...
default: 80 => 80 (adapter 1)
But it worked for me. Now, to actually get to the VM I had to use it's private IP instead of the localhost name:
http://192.168.10.10/
But sure enough my site was there and everything was working. If you decide to keep it that was you can add that IP address to your hosts file to give it a nice short name.
Hope this helps.
I see there is an accepted answer, but this alternative may also help someone.
If I understand correctly you really dislike the port "8000"!
Have you tried setting a private network?
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
/*other config stuff here */
config.vm.network :private_network, ip: "192.168.33.22"
This way you can simply use that IP address, or edit you hosts file to map the local domain to that IP.
Take a look at the Vagrant docs:Vagrant Private Networks
BTW, You shouldn't need to shutdown your IIS local server as that is running on a totally different IP range. I have Apache running locally while also accessing the VM server. This allows you to use tools like composer (to pull in laravel) on your local if needed.
I'm not sure what the confusion is - this is the way it's supposed to work.
The web server on the VM listens on port 80. Vagrant/VirtualBox forwards that port from 80 (on the VM) to 8000 (on localhost) so that you can access the site at http://localhost:8000.
Port 80 on the VM's domain name is not going to be available - that domain name probably resolves to localhost.
Try the following: dig local.kujif.com (or nslookup or even ping - I don't know what tools are available on Windows) to find out what IP address that name is resolving to. You will probably find that it's 127.0.0.1 (localhost).
You could try using the IP address set in the homestead file instead: http://192.168.10.10/ - this might work, but it will depend on how networking is configured in the VM.
Ideally, you need to set networking to "bridged" in the VM - this will make the VM look (to your network) like any other device on the network. Other networking options in the VM (sorry, I'm not familiar with the options in VirtualBox) will set the VM up with its own network that is not accessible outside the VM - this is why port forwarding is used to expose network services on the VM.
You can disable the default port forwarding completely by adding the following to the Homestead.yaml:
default_ports: false
Or configure however you like by adding something like:
ports:
- send: 80
to: 80

How to check jboss running in redhat environment?

I have installed jboss-eap-6.2.0 in redhat environment and started the server.But i'm not able to access the home page via http://<>:8080 .Here i have to access home using ip address or name like http://<>:8080 its getting time out. So i would like to know what is the problem here and why not to see the jboss home here ?
1.Is there any way to check the server running in putty command line ?
2.Able to install the software connecting via ip but same ip is not allowing to access jboss page .So is firewall blocking the port 8080 ?
Please advise
Open the standalone.xml file from the JBOSS_HOME/standalone/configuration directory.
Look for all the texts jboss.bind.address in there and change the ip with the server's IP address so that you can access it from your local pc.
For example
${jboss.bind.address:192.168.1.68}
${jboss.bind.address.management:192.168.1.68}
... and so on...
Also, you can look for the loop back ip address(127.0.0.1) in the xml file as well and replace it.
Even i faced same issue wheni installed jboss7 on centos machine.i found that 8080 port was being used by some other app,thus disabling jboss7 to use that port.
-you can
telnet localhost 8080 (or) ps -ef|grep java
to check if jboss is running
if its running properly and you still not able to connect through your browser
use nmap to check services running on that port
you can edit your port configuration at
jboss/standalone/configuration/standalone.xml
run jboss again
You need to set the value of the default interface in socket-binding as well in your standalone.xml.

Connect to PostgreSql database in Linux VirtualBox from Win7

As said in headline, from Win7 host I'm trying to access Postgres 9.3 established in Linux Centos 5.8 which is in VirtualBox on the same machine. I'm trying to access it from PGAdmin and everything is OK when I start the Postgre from Win7 services, so PGAdmin is well configured.
What have I tried? I've read many articles about this subject, and even some questions on this forum but nothing worked. I have:
switched to NAT and forwarded port 5432 in VirtualBox GUI
set listenadresses = '*' in postgresql.conf file
put host all all 10.0.2.1/24 md5 line in the pg_hba.conf file
put 5432 port inbound and outbound rule in win7 firewall settings
disabled linux firewall with #service iptables stop
Just to mention. When service is started in virtual linux, I can access it from linux, so service is properly started. Problem is that windows doesn't see that service. And when service is started from linux, I can start the same service in Win and vice-versa although the port 5432 should be occupied.
The most suspicious part to me is point 3) because I'm not sure whether i have put good address in rule. That address vary from article to article, and I would appreciate if someone could explain me how to be sure which address (or range) to put there, according to my network. Or some other advice if possible. Thanks.
Solved.
Replacing:
"host all all 10.0.2.1/24 md5" with "host all all 0.0.0.0/0 trust" solved it.
In my case adding the below line to pg_hba.conf was enough:
host all all 10.0.0.0/16 md5
and then restart:
sudo /etc/init.d/postgresql restart
The Solution by Filip works, but you can tailor it further.
First, enable Adapter 2 in VM and set it to Host-only Adapter:
Second go to your host machine and find it's ip address.
This can be found by running ipconfig in your windows host machine.
Now you need to edit two files in your VMBox.
First is postgresql.conf
sudo nano /etc/postgresql/<version>/main/postgresql.conf
and add the following line:
listen_addresses = '*'
save it and then edit pg_hba.conf
sudo nano /etc/postgresql/<version>/main/pg_hba.conf
Here you need to add your host machine ip (in my case it was 192.168.56.1:
host all all 192.168.56.1/0 trust
Save it and restart postgresql
sudo /etc/init.d/postgresql restart
Now you can use pgadmin to connect to vm postgresql.
Convenience!

Resources