Laravel forge - how multiple servers could access same database - laravel

I use Laravel Forge to deploy 2 web apps to the same VPC in AWS like following:
A server ( with MySQL installed ):
- domain: test-erp.foo.com
- ip: 3.112.70.152
B server:
- domain: test.foo.com
- ip: 13.230.27.11
I can access MySQL in A server, but I can not access the MySQL from B server. I need both two web apps to access the same DB and how can I config it in Laravel forge ?

You will need to create a security group for that VPC and a rule that allows the traffic that is needed. For reference.

Related

Can we host laravel application on AWS and use all its service

I'm creating Laravel Application with MySQL but i want to use Amazon RDS, Amazon S3 Bucket AWS Lambda, AWS Route 53 these services.
I want to know whether our laravel application can be hosted on AWS and use these services there or we have to change our laravel application structure/code so that we can use these services.
Thanks
Yes you can.
Here is one of the infrastructure, you can do better as well.
Upload your code to EC2 instance web root - Yo can change your code from here
change config settings for database connection to Amazon RDS DB
Use Amazon Route 53 (DNS) to refer to your public/elastic IP
Hope this will give good idea for your question.
I would recommend Laravel Vapor https://vapor.laravel.com/ it is a bargain for how easy it is to use!

How to securely connect to Azure Cache for Redis from Laravel

Azure Cache for Redis provides secure port for connecting over TLS.
How to setup Laravel Redis config for connecting securely?
Use 6380 port and add tls:// to host.
.env file:
CACHE_DRIVER=redis
REDIS_HOST=tls://RESOURCE_NAME.redis.cache.windows.net
REDIS_PASSWORD=password
REDIS_PORT=6380

Keycloak and Spring Boot web app in dockerized environment

Consider the following environment:
one docker container is keycloak
another docker container is our web app that uses keycloak for authentication
The web app is a Spring Boot application with "keycloak-spring-boot-starter" applied. In application.properties:
keycloak.auth-server-url = http://localhost:8028/auth
A user accessing our web app will be redirected to keycloak using the URL for the exposed port of the keycloak docker container. Login is done without problems in keycloak and the user (browser) is redirected to our web app again. Now, the authorization code needs to be exchanged for an access token. Hence, our web app (keycloak client) tries to connect to the same host and port configured in keycloak.auth-server-url. But this is a problem because the web app resides in a docker container and not on the host machine, so it should rather access http://keycloak:8080 or something where keycloak is the linked keycloak docker container.
So the question is: How can I configure the keycloak client to apply different URLs for browser redirection and access token endpoints?
There used to be another property auth-server-url-for-backend-requests but was removed by pull request #2506 as a solution to issue #2623 on Keycloak's JIRA. In the description of this issue, you'll find the reasons why and possible workarounds: that should be solved at the DNS level or by adding entries to the host file.
So there is not much you can do in the client configuration, unless you change the code and make your own version of the adapter, but there is something you can do at the Docker level. For this to work properly, first I suggest you use a fully qualified domain name instead of localhost for the public hostname, as you would in production anyway, eg. keycloak.mydomain.com. You can use a fake one (not registered in DNS servers) if you just add it to the host's /etc/hosts file (or Windows equivalent) as an alias next to localhost.
Then, if you are using Docker Compose, you can set aliases (alternative hostnames) for the keycloak service on the docker network to which the containers are connected (see doc: Compose File reference / Service configuration reference / networks / aliases). For example:
version: "3.7"
services:
keycloak:
image: jboss/keycloak
networks:
# Replace 'mynet' with whatever user-defined network you are using or want to use
mynet:
aliases:
- keycloak.mydomain.com
webapp:
image: "nginx:alpine"
networks:
- mynet
networks:
mynet:
If you are just using plain Docker, you can do the equivalent with --alias flag of docker network connect command (see doc: Container networking / IP address and hostname).

Connecting Google Compute Engine with Google App Engine

I am trying to connect a Google Compute Engine instance with a MySQL database to Google App Engine using Laravel. I actually have connected my Google App Engine to a Cloud SQL instance, I don't have problem with this, but I need an additional database connection with the database located on Google Compute Engine.
Google Compute Engine instance is on a different project. This is my scheme:
Project A -> Compute Engine -> Instance -> MySQL database
Project B -> App Engine -> Laravel
Project B -> Cloud SQL -> DB-instance -> MySQL database
This is my app.yaml file:
runtime: php
env: flex
runtime_config:
document_root: public
# Ensure we skip ".env", which is only for local development
skip_files:
- .env
env_variables:
# Put production environment variables here.
APP_LOG: "errorlog"
APP_KEY: "[KEY]"
STORAGE_DIR: "/tmp"
CACHE_DRIVER: "database"
SESSION_DRIVER: "database"
APP_DEBUG: "true"
#CLOUD SQL database connection
DB_CONNECTION: "[DATABASE_1_NAME]"
DB_HOST: "[CLOUD_SQL_INSTANCE_NAME]"
DB_DATABASE: "[DATABASE_1_NAME]"
DB_USERNAME: "root"
DB_PASSWORD: "[PASSWORD]"
DB_SOCKET: "/cloudsql/[PROJECTB]:[REGION]:[CLOUD_SQL_INSTANCE_NAME]"
# COMPUTE ENGINE database connection
DB_HOST_2: "[COMPUTE_ENGINE_INSTANCE_NAME]"
DB_DATABASE_2: "[DATABASE_2_NAME]"
DB_USERNAME_2: "root"
DB_PASSWORD_2: "[PASSWORD]"
beta_settings:
cloud_sql_instances: "[PROJECTB]:[REGION]:[CLOUD_SQL_INSTANCE_NAME]"
I consider you're using Google App Engine Standard environment with PHP.
When you connect a GAE Application to a DB hosted on a Google Compute Engine instance, it is treated as a connection to an "external DB". Thus, you need to consider GAE as an external client of your GCE instance.
Therefore, you must configure your VPC firewall in order to accept connections to the port 3306 from outside and you must specify the external GCE instance IP address as the host of your connection string. Be sure that your firewall rule accepts connections from everywhere (IP mask: 0.0.0.0/0).
Hope this helps you.
Bye

how to set pm2 node.js app on windows server?

i have this configuration:
aws EC2 windows server with node.js and pm2 installed on it.
Route 53 domain.
elastic IP for the server.
running app on the server on port 80 using pm2.
my app using express web app framework.
my questions is how to connect the domain name (on route 53) with the pm2 app on the server.
thanks.
Create one record set pointing to EIP of your server in route53 and use.
If you have multiple servers:
Create one ELB
Attach instances to it.
Add CNAME entry from ELB to route53 record set.

Resources