Can I run laravel (admin dashboard) and vue (front-end) in a single domain - vuejs2

I have done a project which admin dashboard is done by using laravel+vus (vue (v2.6) inside laravel(v8)) and front end is done by independent vue(v3) js(getting data from laravel api).can i run this two projects in a single domain.That is frond is will load www.domain.com and admin dashboard will load www.domain.com/admin..Can I do like this.?Routing is enable in vuejs.

You can do that, but typically it is easier to host the backend on a subdomain, e.g. you'd host the backend on something like backend.domain.com and the frontend on domain.com and/or www.domain.com. You can configure a setup like this relatively easy with nginx for example, by setting up two location blocks, one pointing to your Laravel installation, the other one to your vue 3 application.
To get back to your question, you can also set it up like you wanted, e.g. in a subfolder instead of via a subdomain. You can also do that via location blocks with nginx, but then you'd have to make sure that the routes from your backend and your frontend never have any overlap, so I wouldn't recommend to go that way.

Related

Seamlessly hosting different parts of a website in different docker containers

I have a website that I am trying to convert to a docker-compose solution.
Part of the website is a CMS (WordPress, specifically), and there are also a few Java web applications that are currently handled by tomcat.
The current approach is that I have an official WordPress container and an official Tomcat container. I load my custom content in the WordPress (via a MySQL container which is not really a part of this question) and the WAR files into tomcat.
So the problem is this:
Parts of the WordPress website have links to Java applications. Previously, some of these links were relative links as simple as /Application1 and the user would be able to access the Java application.
Now, since they are hosted in separate containers, I cannot do this because there is nothing named "Application1" in the WordPress container. I have modified the htaccess file for the WordPress container with a RewriteRules like this:
# Tomcat exposes port 8085
RewriteRule ^.*Application1/(.*)$ http://localhost:8085/Application1/$1 [R,L]
But this means that if the user clicks the link for Application1 in wordpress, their browser will then redirect them to localhost:8085 - which works fine if you run this set of containers locally, but does not work for remote users.
I could change localhost to the actual name of the server this will run on. But then it would need to be manually updated for every server this stack will run on, or reset to localhost for developers.
I could combine WordPress and Tomcat into a single container, but we were hoping to keep them separate so that when we need to upgrade, we just change the version of the container we are pulling rather than having to rebuild a custom container from scratch.
Is there a more seamless way to do this, so that the URL in the user's browser never changes? Is there way to get this working so that remote users won't even know that the different parts of the site are hosted in different containers?
Assuming you do docker-compose in development and also in production, you replace localhost with servicename of the corresponding upstream.
Lets say, you have 3 containers: httpd, fpm ( wordpress) and java ( tomcat ). You configure httpd, to redirect to fpm:9000 if its domain.tld/php and redirect to java:8086 if the request is domain.tld/Application1.
All you need to understand is, that the actual service-name you have in docker-compose is available as a hostname in the container ( all containers ) - so containers can reach themselfs using the service-name of the other container - that makes inter-container communication very easy and pre-configureable, without knowing the actual container IPs ( which will change during development / production and host migrations )
I think I figured it out: I should have been using a proxy instead of a RewriteRule.
This seems to get me what I want:
ProxyPass "/Application1" "http://my-tomcat-server:8080/Application1"
ProxyPassReverse "/Application1" "http://my-tomcat-server:8080/Application1"

htaccess http request re-routing

Reason for Problem:
I'm working on a website and wanted to work on it without making edits to the live website. My hosting package allows for "infinite" domains. So instead of editing the live website I create a new domain, without purchasing the domain name and am trying to develop with this new domain.
Issue At Hand:
This issue is that the reference file paths don't work anymore and return 404 when trying to load the webpage. My original website directory structure looks like this
cgi-bin
config
public_html
->JSfiles
->CSSfiles
->PHPfiles
The new one is the same structure however when you open the "temporary web address" the URL looks like this
http://217.199.187.199/myTempAddress.com/"
instead of
http://myTempAddress.com/
so when my index.html file looks for /JSfiles/someJSfile.js its requesting
http://217.199.187.199/JSfiles/someJSfile.js
when it needs to be requesting
http://217.199.187.199/myTempAddress.com/JSfiles/someJSfile.js
Things I've Tried Unsuccessfully:
I would really like to fix this by redirecting with the .htaccess file in the root directory on the server. Ive tried using the following directives with no success.
Redirect /217.199.187.199/JSfiles/mustache.min.js http://217.199.187.199/myTempAddress.com/JSfiles/mustache.min.js
Redirect /JSfiles http://217.199.187.199/myTempAddress.com/JSfiles/
Redirect /JSfiles http://217.199.187.199/myTempAddress.com/
Redirect /JSfiles 217.199.187.199/myTempAddress.com/
Question:
How can I redirect the requests to the right location? I need all the the requests to be of the form http://217.199.187.199/myTempAddress.com/someDir/Somefile.ex
You need to read up a bit more on Virtual Hosting in particular name based virtual hosting.
https://httpd.apache.org/docs/current/vhosts/name-based.html
It sounds like your provider might support name based VHosts but what you're trying to do is not taking advantage of that. To do what you want ie have path that points to a different version of your site is best achieved using mod_rewrite. See this
https://httpd.apache.org/docs/2.4/rewrite/remapping.html
You need to make sure that your provided actually supports this.

Masking or changing certain text in URL

I'm using Composer with Toran Proxy hosted on a personal server to manage my package dependencies for Symfony2, today I encountered a problem, one of the URLs that Composer needs to download ends with dependecy-injection.json, every other URL downloads OK, but having those words it's something the proxy doesn't like, so it blocks it.
I have full access to the server, is there a way to mask o change that certain URL to make it look like another one and so "bypassing" the proxy?
This is the URL:
http://domainexample/toran/web/app.php/repo/packagist/p/symfony/dependency-injection.json
I'm using Apache2 as web server.

Correct way of deploying to a subdirectory/subdomain an app that doesn't really support it

I've been trying to deploy kandan to my home server, on a subdirectory, let's say it's example.com.
I have a few constraints I'd like to see met:
must not be at website root (I'm hosting other stuff and apps)
must be secured by SSL (already implemented on example.com but not for subdomains, which I would have to pay for)
kandan does not support being hosted on subdirectories (you can't tell to it that it's hosted on example.com/kandan and have it automatically update its links)
I have listed my attempts here, but here's the gist of it:
tweakings to nginx
adding --prefix=/kandan to thin start
RAILS_RELATIVE_URL_ROOT="/kandan"
map Kandan::Application.config.relative_url_root before run Rack::URLMap... in config.ru
tweaking the content of run Rack::URLMap... in config.ru
scope "/kandan" in routes.rb
config.relative_url_root = "/kandan" in production.rb
many combinations of all the above
None of it did the job.
Currently I can show the main page with some missing elements (JS, API calls failing..) and some working elements (CSS is there..)
Is there a way to fully achieve what I want?

1 domain two separate applications

http://www.one.com
and
http://www.one.com/uk
www.one.com is the main site, but there is a UK version of this site which ideally needs to be in a subdirectory (/uk).
How do set IIS up to allow me to have multiple sites under one domain?
Or can I have two separate sites and use ISAPI_rewrite to point www.one.com/uk to read from another site but keep the url www.one.com/uk?
Could you not just setup a virtual directory that points at the second application? Assuming you are using asp.net, you'd have to make sure there was no overlap in the web.config files (you may have to remove/add some elements) but a virtual directory would be a simple solution I'd think.
You could just set up a virtual directory called "uk" inside the main site for "www.one.com", and place the UK version of the application inside it. You'll need to make sure that the application inside it either uses relative links (to make sure it does not stray out into the main application), or it's absolute links include the /uk/ prefix.
Alternatively, have you considered using two hostnames? E.g., www.one.com for global/ US/ non-UK, and uk.one.com for the UK site?
Just setup a virtual "/uk" directory. http://support.microsoft.com/kb/172138
You can do it with ISAPI_Rewrite with the proxy if you needed to use multiple domains but I would recommend if you had to use multiple domains doing it the easy way by making the second site : uk.one.com using host headers. http://www.visualwin.com/host-header/
Alternatively you could set up subdomain like uk.one.com and redirect user there if he is from uk. It's easier.