Laravel homestead serve documents from root directory - homestead

I have to browse to http://test.local/test/ in order to view index.php. Of course I really want to be able to view this script from http://test.local. What is wrong with my config?
// .homestead/Homestead.yaml
ip: "192.168.0.2"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
- map: test.local
#to: /var/www/test
to: ~/Documents/www/test <-- now pointing to
/etc/hosts
127.0.0.1 localhost
127.0.1.1 andy-desktop
192.168.0.2 test.local
$ ls -l /var/www/test/
total 4
-rwxrwxr-x 1 andy andy 31 May 12 14:22 index.php
and why are my documents being served from /test ?

Related

NGINX containerized server failes to access existing folder and returns Error 404

I'm trying to deploy containerized NGINX server on an AWS EC2 instance to share a directory content over HTTP.
I'm using helm command to deploy the container:
helm install nginx on_premise_configuration/nginx --set ingress.hostname=xxx.yyy.cloud -f ./on_premise_configuration/demo/nginx-values.yml
nginx-values.yml content as follows:
ingress:
enabled: true
service:
type: ClusterIP
containerPorts:
http: 80
serverBlock: |-
server {
listen 0.0.0.0:80;
location / {
root /out;
autoindex on;
}
}
readinessProbe:
enabled: false
livenessProbe:
enabled: false
containerSecurityContext:
enabled: true
runAsUser: 0
runAsNonRoot: false
Directory /out and file /out/index.html do exist and have full 777 access rights.
Deployed pod is running fine:
[root#xxxx]# kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-bbff6c589-7cd7b 1/1 Running 0 2m8s
However any HTTP request attempt is rejected with error 404:
[root#xxxx]# kubectl logs nginx-bbff6c589-7cd7b
nginx 22:08:08.35
nginx 22:08:08.35 Welcome to the Bitnami nginx container
nginx 22:08:08.36 Subscribe to project updates by watching https://github.com/bitnami/bitnami-docker-nginx
nginx 22:08:08.36 Submit issues and feature requests at https://github.com/bitnami/bitnami-docker-nginx/issues
nginx 22:08:08.36
nginx 22:08:08.36 INFO ==> ** Starting NGINX setup **
nginx 22:08:08.37 INFO ==> Validating settings in NGINX_* env vars
nginx 22:08:08.39 INFO ==> Initializing NGINX
nginx 22:08:08.40 INFO ==> ** NGINX setup finished! **
nginx 22:08:08.41 INFO ==> ** Starting NGINX **
2021/03/29 22:08:37 [error] 36#36: *1 "/out/index.html" is not found (2: No such file or directory), client: 10.42.0.111, server: , request: "GET / HTTP/1.1", host: "xxx.yyy.cloud"
10.42.0.111 - - [29/Mar/2021:22:08:37 +0000] "GET / HTTP/1.1" 404 180 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.57"
No matter what request is for - individual file or directory listing.
I re-iterate once again - the server is running on AWS EC2 instance and I might've missed some AWS specific configuration.
I've tried different yml versions but nothing is working and I actually run out of ideas.
I would really appreciate for any advice how to resolve it.
After some investigation I've realized that yml file doesn't contain mounting points between host folder and internal pod's filesystem.
In fact NGINX was searching /out folder inside the pod while I was trying to share the host folder.
Perhaps the original question needs to be updated to highlight that host folder to be shared by using contenerized NGINX
Anyway, once I've updated yml file everything started working. correct nginx-values.yml version:
ingress:
enabled: true
service:
type: ClusterIP
containerPorts:
http: 80
serverBlock: |-
server {
listen 0.0.0.0:80;
location /output {
root /opt/bitnami/nginx/html/;
autoindex on;
}
}
readinessProbe:
enabled: false
livenessProbe:
enabled: false
containerSecurityContext:
enabled: true
runAsUser: 0
runAsNonRoot: false
extraVolumes:
- name: centos
hostPath:
# directory location on host
path: /out
# this field is optional
type: Directory
extraVolumeMounts:
- name: centos
mountPath: /opt/bitnami/nginx/html/output
the above yml is mounting host folder /out to pod's folder /opt/bitnami/nginx/html/output

How to get root password in Bitnami Wordpress from kubernetes shell?

I have installed Worpress in Rancher, (docker.io/bitnami/wordpress:5.3.2-debian-10-r43) I have to make wp-config writable but I get stuck, when get shell inside this pod to log as root :
kubectl exec -t -i --namespace=annuaire-p-brqcw annuaire-p-brqcw-wordpress-7ff856cd9f-l9gf7 bash
I cannot login to root, no password match with Bitnami Wordpress installation.
wordpress#annuaire-p-brqcw-wordpress-7ff856cd9f-l9gf7:/$ su root
Password:
su: Authentication failure
What is the default password, or how to change it ?
I really need your help!
The WordPress container has been migrated to a "non-root" user
approach. Previously the container ran as the root user and the Apache
daemon was started as the daemon user. From now on, both the container
and the Apache daemon run as user 1001. You can revert this behavior
by changing USER 1001 to USER root in the Dockerfile.
No writing permissions will be granted on wp-config.php by default.
This means that the only way to run it as root user is to create own Dockerfile and changing user to root.
However it's not recommended to run those containers are root for security reasons.
The simplest and most native Kubernetes way to change the file content on the Pod's container file system is to create a ConfigMap object from file using the following command:
$ kubectl create configmap myconfigmap --from-file=foo.txt
$ cat foo.txt
foo test
(Check the ConfigMaps documentation for details how to update them.)
then mount the ConfigMap to your container to replace existing file as follows:
(example requires some adjustments to work with Wordpress image):
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mypod
image: nginx
volumeMounts:
- name: volname1
mountPath: "/etc/wpconfig.conf"
readOnly: true
subPath: foo.txt
volumes:
- name: volname1
configMap:
name: myconfigmap
In the above example, the file in the ConfigMap data: section replaces original /etc/wpconfig.conf file (or creates if the file doesn't exist) in the running container without necessity to build a new container.
$ kubectl exec -ti mypod -- bash
root#mypod:/# ls -lah /etc/wpconfig.conf
-rw-r--r-- 1 root root 9 Jun 4 16:31 /etc/wpconfig.conf
root#mypod:/# cat /etc/wpconfig.conf
foo test
Note, that the file permissions is 644 which is enough to be readable by non-root user.
BTW, Bitnami Helm chart also uses this approach, but it relies on the existing configMap in your cluster for adding custom .htaccess and persistentVolumeClaim for mounting Wordpress data folder.

How to access website running locally with custom domain & SSL on mobile phone?

I have a WordPress (WP) blog running locally on my machine (OSX). The WP Site URL setting is set to https://abc.dev and I can access the site without any problem on my machine's browser.
Visually, it looks like this:
The WP site running on port 443 and I'm using a self-signed certificate to make it work. I obtained the self-signed cert from this website. I've imported the self-signed cert into OSX Keychain Access and marked it Always Trust.
This is how my docker-compose.yml file for that WP looks like:
version: '2'
services:
wordpress:
build: .
ports:
- 8080:80
volumes:
- ./config/php.conf.uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
- ./wp-app:/var/www/html # Full wordpress project
#- ./plugin-name/trunk/:/var/www/html/wp-content/plugins/plugin-name # Plugin development
#- ./theme-name/trunk/:/var/www/html/wp-content/themes/theme-name # Theme development
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: password
depends_on:
- db
networks:
- wordpress-network
db:
image: mysql:latest
ports:
- 127.0.0.1:3306:3306
command: [
'--default_authentication_plugin=mysql_native_password',
'--character-set-server=utf8mb4',
'--collation-server=utf8mb4_unicode_ci'
]
volumes:
- ./wp-data:/docker-entrypoint-initdb.d
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
networks:
- wordpress-network
caddy:
image: abiosoft/caddy
restart: always
ports:
- "80:80"
- "443:443"
links:
- wordpress
volumes:
- "./Caddyfile:/etc/Caddyfile"
- "./caddy:/var/caddy"
networks:
- wordpress-network
networks:
wordpress-network:
driver: bridge
And this is the Caddyfile:
abc.dev:443
root /var/www/html
tls /var/caddy/cert.pem /var/caddy/key.pem
proxy / wordpress {
transparent
}
log stdout
errors stderr
The tree structure looks like this:
├── Caddyfile
├── caddy
│   ├── cert.pem
│   └── key.pem
└── docker-compose.yml
Opened ports by Docker Compose:
$ lsof -PiTCP -sTCP:LISTEN | grep com.dock
com.docke 497 zz 18u IPv4 0xc97e1c7b362c847b 0t0 TCP localhost:3306 (LISTEN)
com.docke 497 zz 23u IPv6 0xc97e1c7b3aa15d0b 0t0 TCP localhost:3306 (LISTEN)
com.docke 497 zz 24u IPv4 0xc97e1c7b50618b83 0t0 TCP *:8080 (LISTEN)
com.docke 497 zz 25u IPv6 0xc97e1c7b3aa1624b 0t0 TCP localhost:8080 (LISTEN)
com.docke 497 zz 27u IPv4 0xc97e1c7b39e63b83 0t0 TCP *:443 (LISTEN)
com.docke 497 zz 28u IPv4 0xc97e1c7b5061b85b 0t0 TCP *:80 (LISTEN)
The main reason why I open wordpress port at 8080 was because Caddy wanted 80 and 443 ports to be opened. So, by doing that, it helped me with port conflicts problem.
My problem right now, I want to access the WP site on my phone and I want the URL to be https://abc.dev as well in the phone.
For the past few days, I've been messing around with Squid proxy and Mitmproxy and didn't find any luck.
Some of the things that I've tried in general:
Set up proxy using SquidMan
Set up Mitmproxy running reverse mode
Set up Mitmproxy running upstream mode
Install and trust Mitmproxy cert in my phone
Set up Ubuntu 18 Server VM on top my machine (OSX) using VirtualBox, install Mitmproxy, run Mitmproxy, configure host (OSX) and phone to use that Ubuntu 18 Server as proxy
All of the steps above didn't work for me and I'm out of idea how to make this setup works for me.
I don't want to change the WP Site URL setting to other URL i.e. http://localhost[:port] or https://localhost[:port] because it's working fine on my machine.
Plus, I want my setup to look and behave as close as my production website which is running using the same URL structure, https://example.com.
I found CharlesProxy but I'm not into it because it's a paid software. I'm sure Squid, Mitmproxy and some other tools out there can help me with this. I'm just not sure how to do it.
Really appreciate for all assistance and pointers.
Answer
At first make sure your problem is only DNS. You should be able to connect to website from your phone to IP of your computer http://COMPUTER_IP. If your are not able load website, check firewall.
Your localhost computer knows abc.dev and resolve it to localhost.
But this is not true for anothers hosts in home network. Another Windows/Mac/Linux only need to add domain entry into hosts file. In Linux it could then looks like
/etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
COMPUTER_IP abc.dev
But for phones it is not easy to rule custom DNS records because of security reasons.
One possible solution, use existing DNS server at home:
If your home router can add static DNS entries. Add custom DNS entry in your home router to point abc.dev to your computer home network IP address.
Second possible solution, use online DNS service:
This one does not use abc.dev, but something what online services offers, for example on https://www.noip.com/ you can register something like abc1234.ddns.net, then setup COMPUTER_IP as IP for that domain. In caddy you use same domain abc1234.ddns.net.
This way your phone will ask noip for IP of abc1234.ddns.net it answers your COMPUTER_IP and browser connect to your computer.
Third possible solution:
Deploy your DNS server with docker-compose together with wordpress.
Setup your COMPUTER_IP as DNS server in your phone.
To try this, add these files to your docker-compose project.
dnsmasq/dnsmasq.conf is working config file, but you need to change last line:
address=/abc.dev/COMPUTER_IP
Put IP address of your computer instead COMPUTER_IP.
directory structure with your docker-compose.yml:
docker-compose.yml
dnsmasq/dockerfile
dnsmasq/dnsmasq.conf
... other files
your docker-compose.yml
version: '2'
services:
wordpress:
...
db:
...
caddy:
...
dnsmasq:
build:
context: .
dockerfile: ./dnsmasq/dockerfile
ports:
- "53:53/udp"
cap_add:
- NET_ADMIN
...
dnsmasq/dockerfile
FROM andyshinn/dnsmasq
COPY dnsmasq/dnsmasq.conf /etc/dnsmasq.conf
CMD ["--log-facility", "-"]
dnsmasq/dnsmasq.conf
# default dnsmasq config file
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv
# use DNS server 8.8.8.8 for all except abc.dev
# you can use IP of your home router
server=8.8.8.8
no-hosts
expand-hosts
user=dnsmasq
group=dnsmasq
cache-size=2048
neg-ttl=60
log-queries
# put IP address of your computer instead COMPUTER_IP
address=/abc.dev/COMPUTER_IP
For more about dnsmasq config see manpage.

My server's IP is redirecting to one folder automatically

I've an account in Digitalocean, they gave me my droplet's IP address and I have a lot of proyects separated in folders, mainly wordpress, prestashop and html.
ls -l www/
drwxrwxr-x 5 www-data www-data 4096 sep 17 12:36 mainwordpress
drwxr-xr-x 20 www-data www-data 4096 may 7 2015 anotherwordpress
drwxrwxr-x 6 www-data www-data 4096 sep 17 13:21 lastwordpress
drwxr-xr-x 6 www-data www-data 4096 ago 11 2015 prestashop
drwxr-xr-x 6 www-data www-data 4096 abr 1 2015 html
I have some domains that point to each and every wordpress and prestahop folders, so I could make the installation correctly and I can access them without an error. But when I try to access my HTML proyect, which has no domain and I access it via http://my_server_ip/html, it redirects me to one of the wordpress proyects, exactly to mainwordpress, and of course giving an error of not finding the page (404).
I've checked my domain's configuration, and every wordpress proyect has an A register to my server's IP, also the prestashop:
MAINWORDPRESS
A: # my_server_ip
A: subdomain my_server_ip
CNAME: www mainwordpress.com
CNAME: *.subdomain subdomain.mainwordpress.com
MX: 0 mainwordpress.com
ANOTHERWORDPRESS
A: # my_server_ip
A: sub1 my_server_ip
A: sub2 my_server_ip
A: sub3 my_server_ip
A: www my_server_ip
A: * my_server_ip
CNAME: *.subdomain subdomain.anotherwordpress.com
LASTWORDPRESS
A: # my_server_ip
A: sub my_server_ip
CNAME: www lastwordpress.com.
CNAME: *.sub sub.lastwordpress.com.
PRESTASHOP
A: # my_server_ip
CNAME: www my_prestashop.com.
I'm completely lost. When I try to enter an URL via my server's IP (http://my_server_ip/html, or http://my_server_ip/whatever, or http://my_server_ip/askdhjfgaksjhdfgs) it goes to mainwordpress' 404 page. What other configurations should I look?
Thank you in advance!!
The default name-based vhost for an IP and port combination If no
matching ServerName or ServerAlias is found in the set of virtual
hosts containing the most specific matching IP address and port
combination, then the first listed virtual host that matches that will
be used.
https://httpd.apache.org/docs/2.4/vhosts/name-based.html#alg
Your problem is most likely the order of your virtual hosts. Unless you specify the IP address in the ServerAlias directive it uses the first virtual host as the default host if navigating from the server IP. So however your setup is, apache is reading your mainwordpress vhost first.
You can change the order and make html first or try adding the server ip to the ServerAlias directive on the html vhost.
Then restart Apache.

I am not able to Launch a VM/instance in proxmox from Salt-master

I have installed Saltsatck(salt-master) on my virtual machine and also installed Proxmox(Cloud) on another virtual machine.
They both are on same network.
Salt-master and proxmox are running successfully.
Whenever I run the below command :-
# salt-cloud -p my-proxmox-config mytest
I get the following output :-
[INFO ] salt-cloud starting
[INFO ] Starting new HTTPS connection (1): 192.168.2.245
[INFO ] Creating Cloud VM mytest
[ERROR ] Error creating mytest on PROXMOX
The following exception was thrown when trying to run the initial deployment:
Error: There was a profile error: Failed to deploy VM
Please look at the below config files :-
1. /etc/salt/cloud.providers.d/proxmox.conf
proxmox-config:
user: root#pam or root#pve
password: oodles
url: 192.168.2.245
driver: proxmox
verify_ssl: False
minion:
master: 192.168.2.228
2. /etc/salt/cloud.profiles.d/proxmox.conf
my-proxmox-config :
provider: proxmox-config
image: /root/ISO/ubuntu-14.04-server-amd64.iso
technology: kvm / Openvz
host: cloud
ip_address: 192.168.2.245
ssh_username: root
password: oodles
cpus: 1
memory: 512
swap: 512
disk: 2
nameserver: 8.8.8.8 8.8.4.4
Please suggest/advice me what to correct from my configurations file .
Thanks
The error you're getting is saying that something is wrong with your profile config. We just need to troubleshoot what's going on with it.
I haven't used the proxmox provider, but according to https://docs.saltstack.com/en/latest/topics/cloud/proxmox.html it looks like for the image option you might have to use local:/root/ISO/ubuntu-14.04-server-amd64.iso.
Also, have you tried just technology: openvz?
I am able to solve the above issue i.e. now I am able to launch a VM/instance in proxmox from salt-master by doing the below configurations :-
1. /etc/salt/cloud.providers.d/proxmox.conf
proxmox-config:
minion:
master_type: standard
master: '192.x.x.x'
user: 'root#pam'
password: "your password"
url: '192.168.x.x'
port: '8006'
driver: proxmox
verify_ssl: False
2. /etc/salt/cloud.profiles.d/proxmox.conf
my-proxmox-config :
provider: proxmox-config
image: local:vztmpl/ubuntu-12.04-standard_12.04-1_i386.tar.gz
technology: openvz
host: cloud
ip_address: 192.168.x.x
ssh_username: root
password: "your password"
cpus: 1
memory: 512
swap: 512
disk: 2
nameserver: 8.8.8.8 8.8.4.4
In the above file, the image option will only work if you have downloaded the desired operating ISO in templates option available in PROXMOX GUI.
Now , you can easily launch a Instance by using below command :-
# salt-cloud -p my-proxmox-config mytest
Thanks

Resources