gecche / laravel-multidomain

A Laravel extension for using a laravel application on a multi domain setting
MIT License
838 stars 105 forks source link

When loading 2 different domains at the same time, it fails to load under a single domain #33

Closed HP161 closed 4 years ago

HP161 commented 4 years ago

Please help me. When loading 2 different domains at the same time, it fails to load under a single domain. Canot load page by Queue.

gecche commented 4 years ago

Hi,

I don't understand your question: could you give me more details and possibly some example?

Thank you

Giacomo

Il giorno gio 27 ago 2020 alle ore 03:36 Đậu Hoàng Phương < notifications@github.com> ha scritto:

Please help me. When downloading 2 different domains at the same time, it fails to load under a single domain. Canot load page by Queue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA2JPH4FSZIK3XPGRFDSCW2BBANCNFSM4QMOAJUA .

HP161 commented 4 years ago

i have 2 domain , the first ,i loading domain A ,after i continue loading domain B in time => result domain B convert to domain A. Theme of domain B cannot load. Please help me! f1 f3

gecche commented 4 years ago

but from what I see, the url displayed in the browser is the same. I think that this is probably due to your webserver configuration which redirects requests of domain B to A and not due to the Laravel application nor my package.

Please check your webserver configuration, and If you are sure that it is an applicaton problem, I could try to help only if you show me the real code about domain configuration and so on.

cheers

giacomo

Inviato da iPhone

Il giorno 27 ago 2020, alle ore 09:55, Đậu Hoàng Phương notifications@github.com ha scritto:

 i have 2 domain , the first ,i loading domain A ,after i continue loading domain B in time => result domain B convert to domain A. Theme of domain B cannot load.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

HP161 commented 4 years ago

Thanks for reply. Can you tell more clearly which code file to see?

gecche commented 4 years ago

Hi,

first af all the virtual hosts configration of your apache/nginx.

Then the folder structure of your app in which the domains configurations have been put.

Are you sure that you don't have a redirect from B to A? Because the problem is that if the url in the browser is the same, the package always loads the same configuration and hence the same theme. But my package does not perform redirects at all, so if you write in the browser domainB.com there is no possibility that my package redirects it to domainA.com

Cheers

Giacomo

Il giorno gio 27 ago 2020 alle ore 11:53 Đậu Hoàng Phương < notifications@github.com> ha scritto:

Thanks for reply. Can you tell more clearly which code file to see?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-681847636, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA4SIMHCYK3YCH3RDVTSCYUIHANCNFSM4QMOAJUA .

HP161 commented 4 years ago

1.config vhost apache: <VirtualHost > DocumentRoot "C:/xampp/htdocs/ocop-hoa-binh/public/" ServerName ocopgli.com.vn ErrorLog "logs/word-error.log" ServerAlias .dhphuong.com.vn <Directory "C:/xampp/htdocs/ocop-hoa-binh/public/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all <VirtualHost > DocumentRoot "C:/xampp/htdocs/ocop-hoa-binh/public/" ServerName ocophbh.com.vn ErrorLog "logs/word-error.log" ServerAlias .ocophbh.com.vn <Directory "C:/xampp/htdocs/ocop-hoa-binh/public/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all

  1. Themes is run good as domains. i have upload image attachs f5
  2. config .env :

QUEUE_CONNECTION=redis BROADCAST_DRIVER=pusher

CACHE_DRIVER=redis CACHE_PREFIX=sdc_cache

SESSION_DRIVER=redis SESSION_LIFETIME=120 SESSION_SECURE_COOKIE=false

REDIS_HOST=.... REDIS_PASSWORD= REDIS_PORT=6379 REDIS_DB=0

gecche commented 4 years ago

Hi,

I'm sorry but it is a bit difficult to understand and to help.

In the screenshots you sent me before, there is a domain called:

ocopgli.com.vn

but there is no reference of such domain in the virtual hosts.

Furthermore you sent me the folder structure about themes which is not related to my package. I meant the folder structure related to my packages: the .env files (one for each domain) and the storage folder structure.

Last thing: instead of loading Laravel have you checked the output of a very simple index.php page in your root folder like the following under the various domains?

<?php echo $_SERVER['SERVER_NAME']; ?>

Cheers

Giacomo

Il giorno ven 28 ago 2020 alle ore 03:10 Đậu Hoàng Phương < notifications@github.com> ha scritto:

1.config vhost apache: <VirtualHost > DocumentRoot "C:/xampp/htdocs/ocop-hoa-binh/public/" ServerName ocopgli [image: f5] https://user-images.githubusercontent.com/4498007/91509846-901ab880-e905-11ea-9335-36151cd121e2.png .com.vn ErrorLog "logs/word-error.log" ServerAlias .dhphuong.com.vn <Directory "C:/xampp/htdocs/ocop-hoa-binh/public/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all

<VirtualHost > DocumentRoot "C:/xampp/htdocs/ocop-hoa-binh/public/" ServerName ocophbh.com.vn ErrorLog "logs/word-error.log" ServerAlias .ocophbh.com.vn <Directory "C:/xampp/htdocs/ocop-hoa-binh/public/"> Options Indexes FollowSymLinks MultiViews AllowOverride all Order allow,deny Allow from all

  1. Themes is run good as domains. i have upload image attachs
  2. config .env :

QUEUE_CONNECTION=redis BROADCAST_DRIVER=pusher

CACHE_DRIVER=redis CACHE_PREFIX=sdc_cache

SESSION_DRIVER=redis SESSION_LIFETIME=120 SESSION_SECURE_COOKIE=false

REDIS_HOST=.... REDIS_PASSWORD= REDIS_PORT=6379 REDIS_DB=0

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-682268518, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOAZJHOCJBDWB6VUWNJTSC37YRANCNFSM4QMOAJUA .

HP161 commented 4 years ago

thanks you! code bootstrap/app here: $app = new Gecche\Multidomain\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(DIR) );

$app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class );

$app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class );

$app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class );

can you check code this? I have 2 file env: .env.ocopgli.com.vn; .env.ocophbh.com.vn

gecche commented 4 years ago

Hi,

your bootstrap/app.php file seems ok.

But what is the result of the check I suggested in my previous email? Please replace temporarily the public/index.php file with a simple php file like this:

<?php echo $_SERVER['SERVER_NAME'] ?>

What is displayed in the browser with the urls:

ocopgli.com.vn http://env.ocopgli.com.vn/ and ocophbh.com.vn http://env.ocophbh.com.vn/?

Cheers

Giacomo

Il giorno sab 29 ago 2020 alle ore 03:48 Đậu Hoàng Phương < notifications@github.com> ha scritto:

thanks you! code bootstrap/app here: $app = new Gecche\Multidomain\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(DIR) ); /* Bind Important Interfaces

Next, we need to bind some important interfaces into the container so we will be able to resolve them when needed. The kernels serve the incoming requests to this application from both the web and CLI.

*/

$app->singleton( Illuminate\Contracts\Http\Kernel::class, App\Http\Kernel::class );

$app->singleton( Illuminate\Contracts\Console\Kernel::class, App\Console\Kernel::class ); $app->singleton( Illuminate\Contracts\Debug\ExceptionHandler::class, App\Exceptions\Handler::class );

can you check code this? I have 2 file env: .env.ocopgli.com.vn; .env.ocophbh.com.vn

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-683216910, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOAYEOGA6ES6V7TXHO53SDBNAHANCNFSM4QMOAJUA .

HP161 commented 4 years ago

thank you! here is result $_SERVER['SERVER_NAME'] with 2 domain s1 s2 This is video description bug: https://www.youtube.com/watch?v=4N58-_eZMLM Please help me

gecche commented 4 years ago

Ok,

then try this example:

replace your routes/web.php file with this simple one:

<?php

Route::get('/', function () { echo env('DOMAINNUMBER',3); return; });

and check the result in the browser with the urls:

ocopgli.com.vn http://env.ocopgli.com.vn/ and ocophbh.com.vn http://env.ocophbh.com.vn/

If you get 1 and 2 respectively my package should work fine and you should find a bug in other area of your application.

Cheers

Giacomo

Il giorno mar 1 set 2020 alle ore 03:23 Đậu Hoàng Phương < notifications@github.com> ha scritto:

thank you! here is result $_SERVER['SERVER_NAME'] with 2 domain [image: s1] https://user-images.githubusercontent.com/4498007/91784146-6080ee80-ec2c-11ea-82d2-d80ad48fc306.png [image: s2] https://user-images.githubusercontent.com/4498007/91784150-61b21b80-ec2c-11ea-97df-47dc5a442838.png

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-684135351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA2GAIIT7KXKYOMITSTSDREJHANCNFSM4QMOAJUA .

HP161 commented 4 years ago

When load 2 domain at time then: echo env('DOMAINNUMBER',3); result: 1 or 2

I thinks package of you not problem. I think when integrated with my project then create a bug that. Can you support me fix this Bug? Thanks you!

gecche commented 4 years ago

Sure, no problem, but it is a bit difficult to help without having access to the full code :)

Giacomo

Il giorno gio 3 set 2020 alle ore 03:46 Đậu Hoàng Phương < notifications@github.com> ha scritto:

I thinks package of you not problem. I think when integrated with my project then create a bug that. Can you support I fix this Bug? Thanks you!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-686182575, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA3WGT7MRRWFAFEVILDSD3YQ5ANCNFSM4QMOAJUA .

HP161 commented 4 years ago

Full code is not oke. bescause I work for hire. Or which file do you want to see, I will send to you Can you send project example to me? thanks for reply!

gecche commented 4 years ago

Hi,

I don't want access to your full code :) I only said that it is difficult to help without seeing it.

I don't have a project example to send: simply start from a plain Laravel installation and add only my package to composer.json. Then try to add 2 or more domains handled by your virtual hosts and see how it works.

Then if you have a specific question I could try to help, but without seeing the whole app I can't do much more.

Giiacomo

Il giorno gio 3 set 2020 alle ore 11:47 Đậu Hoàng Phương < notifications@github.com> ha scritto:

Full code is not oke. bescause I work for hire. Can you send project example to me? thanks for reply!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-686379321, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA65SPKYPQLEBVUI73TSD5Q3XANCNFSM4QMOAJUA .

HP161 commented 4 years ago

Thanks you very much. Here is code config/domain.php, Can you check code? additional anything ? <?php

return [ 'env_stub' => '.env', 'storage_dirs' => [ 'app' => [ 'public' => [ ], ], 'framework' => [ 'cache' => [ ], 'testing' => [ ], 'sessions' => [ ], 'views' => [ ], ], 'logs' => [ ], ], 'domains' => [ 'ocopgli.com.vn' => 'ocopgli.com.vn', 'ocophbh.com.vn' => 'ocophbh.com.vn', ], ];

gecche commented 4 years ago

Hi,

your configuration seems ok. But have you checked if there is any error in the laravel logs?

If not, first you should try to execute, under the two domains, a very basic route displaying an environment value (for example the DB_DATABASE entry) and see what happens. If the route displays correctly the two disitnct database names, then modify the code by connecting to the db and displaying a table content. Better if you do this by using a Controller returning a view.

Giacomo

Il giorno ven 4 set 2020 alle ore 03:33 Đậu Hoàng Phương < notifications@github.com> ha scritto:

Thanks you very much. Here is code config/domain.php, Can you check code? additional anything ? '.env', 'storage_dirs' => [ 'app' => [ 'public' => [ ], ], 'framework' => [ 'cache' => [ ], 'testing' => [ ], 'sessions' => [ ], 'views' => [ ], ], 'logs' => [ ], ], 'domains' => [ 'ocopgli.com.vn' => 'ocopgli.com.vn', ' ocophbh.com.vn' => 'ocophbh.com.vn', ], ];

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-686847991, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA6NBLAYIXJ4MJWILYLSEA7YFANCNFSM4QMOAJUA .

HP161 commented 4 years ago

I have found the cause. echo env('DB_DATABASE') result: same database, Here is images: bug1 bug 2 The system cannot get information from the .env file. Please support

gecche commented 4 years ago

Hi,

but in a previous email I suggested you a simpler check than this, and you did not tell me what were the results. The check is:

/****/

replace your routes/web.php file with this simple one:

<?php

Route::get('/', function () { echo env('DOMAINNUMBER',3); return; });

and check the result in the browser with the urls:

ocopgli.com.vn http://env.ocopgli.com.vn/ and ocophbh.com.vn http://env.ocophbh.com.vn/

You should get 1 and 2 respectively /****/

What you display in the browser? Could you send me the results displaying also the url in the browser? Because if you see 1 and 2 the application reads perfectly the specific .env files.

Il giorno ven 4 set 2020 alle ore 11:48 Đậu Hoàng Phương < notifications@github.com> ha scritto:

I have found the cause.

result: same database, Here is images: [image: bug1] https://user-images.githubusercontent.com/4498007/92226020-436b4a80-eece-11ea-9a50-dc27171dec9d.png [image: bug 2] https://user-images.githubusercontent.com/4498007/92226026-449c7780-eece-11ea-9716-6112a546c091.png The system cannot get information from the .env file. Please support

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-687044636, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA7CV3457BRL5QPIOGLSECZXBANCNFSM4QMOAJUA .

HP161 commented 4 years ago

Hi. Route::get('/', function () { echo env('DOMAINNUMBER',3); return; }); result: 1. when load 2 url at time then result: 1 or 2 I mentioned in the previous email /*

When load 2 domain at time then: echo env('DOMAINNUMBER',3); result: 1 or 2 */ When load 2 domain at time then, I print code is below print_r($app->environmentFile()) ; result: http://ocopgli.com.vn/ => .env.ocopgli.com.vn http://ocophbh.com.vn/ => .env.ocophbh.com.vn file .env is oke, But when loading the values in it are not correct. I think so You give me solution to fix it? Thanks!

gecche commented 4 years ago

Hi,

no, I have not a ready solution also because you are the first reporting an issue like that. I think that, using the last setting with the DOMAINNUMBER entry, you should debug your application and see what happens when executing the method

detectWebDomain

in the file

Foundation/DomainDetector.php

of my package.

If the result of that method does not correspond to the domain you have in the url browser, I think that there is a problem in your server/virtual machine settings.

Let me know.

Giacomo

Il giorno sab 5 set 2020 alle ore 02:42 Đậu Hoàng Phương < notifications@github.com> ha scritto:

Hi. Route::get('/', function () { echo env('DOMAINNUMBER',3); return; }); result: 1. when load 2 url at time then result: 1 or 2 I mentioned in the previous email /*

When load 2 domain at time then: echo env('DOMAINNUMBER',3); result: 1 or 2 */ You give me solution to fix it? Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-687494939, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOAYR25PV4FCYRM5QBZTSEGCOPANCNFSM4QMOAJUA .

HP161 commented 4 years ago

I think the domain name is still correct. But when get the configuration values in .env is not correct. It's just wrong to load 2 domains at the same time. return Arr::get($_SERVER,'SERVER_NAME'); http://ocopgli.com.vn => ocopgli.com.vn http://ocophbh.com.vn => ocophbh.com.vn Can you find me the solution?

gecche commented 4 years ago

Ok,

so, if you are sure the SERVER_NAME is still correct, you should do a last debug, seeing the executions of methods

'environmentFile' and 'environmentFileDomain'

in the file

'Foundation/Application.php'

of my package.

In those methods, the package loads the right environment file depending on the domain found before.

A last question: the config has not been cached right? If so please clear it before debug

Giacomo

Il giorno lun 7 set 2020 alle ore 03:29 Đậu Hoàng Phương < notifications@github.com> ha scritto:

I think the domain name is still correct. But when get the configuration values in .env is not correct. It's just wrong to load 2 domains at the same time. return Arr::get($_SERVER,'SERVER_NAME'); http://ocopgli.com.vn => ocopgli.com.vn http://ocophbh.com.vn => ocophbh.com.vn Can you find me the solution?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-687967152, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA2QDFEUYP3M7KL23I3SEQZQJANCNFSM4QMOAJUA .

HP161 commented 4 years ago

It is oke! Thank you very much!

gecche commented 4 years ago

? What happened?

Il giorno mar 8 set 2020 alle ore 10:42 Đậu Hoàng Phương < notifications@github.com> ha scritto:

It is oke! Thank you very much!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gecche/laravel-multidomain/issues/33#issuecomment-688717217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUUOA75FRFQYTNVX5WG74LSEXU6RANCNFSM4QMOAJUA .

HP161 commented 4 years ago

You are closed issue! thank you

gecche commented 4 years ago

Ok,

I close the issue.

If you liked the package please leave a star and spread the word ;)

Cheers

Giacomo