base url redirecting for absolute urls - redirect

I'm dealing with an annoying problem. I have to make some changes to a large website, which source code is not under my control (sub-contracting). As usually I try to rebuild a local copy of the site to test my changes. The problem is now that almost all paths used in URLs for images, css, links etc. are relative paths pointing to the root directory, like
href="/style/main.css"
This is a problem because I develop on an intranet server and I put this project into a nested directory, so the URL to the project files is sth. like
http://myIntranet.com/checkout/project
What happens is that the paths from the first example don't resolve correctly. So I tried using the base tag to set the directory from which links should be resolved as
That works fine when the path is
href="style/main.css"
without the slash at the start, but fails when the slash exists, because (I think) the link is resolved from the server host, not from the URI in the tag.
So... is there any possibility to make the "/dir/file.html" links resolve from a root othe than the server root? Or do I have to manually remove all prepending slashes from the paths (urgh)?
Thanks in advance. :)

If you're doing local development on a web site you can do either of the below. Both involve moving your project in a base folder instead of working with sub folders inside your document root.
Virtual host on different port
In your web server, create another listening port and virtual host.
After restart, you can access your web server as http://localhost:81 or whatever port number you choose.
Virtual host on same port
Only create another virtual host (like above), but make sure to use named virtual hosting.
After restart, you have to add another entry in your hosts file (c:\windows\system32\drivers\etc\hosts or /etc/hosts) using a simple text editor:
127.0.0.1 localhost myproject1.self.com
The above line should already exist, so you can keep adding more names to it:
127.0.0.1 localhost myproject1.self.com myproject2.self.com
Personal preference
I like the second option, because I don't have to mess with ports and stuff like Facebook API keeps working as you expect.
I hope this all makes sense, let me know otherwise.

Related

How do I make a golem app appear at a specific URL route

We let the golem package automatically create a Dockerfile for us and can run the docker image and see the app at the root directory: http://localhost:3838/?...
But we would like the app to appear in a subdirectory like http://localhost:3838/myApp/v1/?... so that we can set up the necessary proxying for Apache and have this and other apps all available from a single server.
We can manually edit the Dockerfile to copy a shiny-server.conf file with the following information:
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location /myApp/v1/ {
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
}
}
The above solution feels like a hack and we are hoping there is functionality inside of golem that will allow us to set the subdirectory at which the app will appear.
Unfortunately there is no way to include an nginx configuration inside the Dockerfile programmatically: {golem} tries to help with the creation of the file, but some things still need to be done manually.
Also, note that {golem} doesn't create a Dockerfile with a shiny server in it, it creates a standalone docker image that launches the app, so there is no shiny server running, just an R process. {shiny} being what it is, there is no way to natively run it on a given path, it's always at the root, on a port.
That being said, what you can do is either edit the dockerfile so that it also bundle nginx (or any other load balancer), so that you can serve the app on a path, or serve your application on another port, using the port argument of add_dockerfile(): that might be easier to configure it with you Apache proxy.
Colin

Parse Server - Can't Access Images

I have a Parse Server running on top of a MongoDB, and that's running 100% fine on my Dev Server which is hosted on DigitalOcean. Here I'm able to send GET requests to my server to obtain the image, as well as access the image via it's Parse-Dashboard.
I cloned that droplet to set up a Production Server, and everything is running fine... Except, I can't access the images from Parse that were either cloned from the Dev Server, or ones that I uploaded after I initialized the new Production server. I'm able to send GET requests to obtain all other fields, except for the image files. I also can't access the image file via the Parse-Dashboard - it returns a 404 - Oh no, we can't find that page! error, on the following URL: http://server.ip/parse/files/ProdServer/de632aeb61f7265926e554fabfb25180_image1.png
Other key things to note:
The Dev Server is hosted on a domain that has a SSL; could it be an SSL issue?
I'm initializing the parse-dashboard with the --allowInsecureHTTP flag
Everything (even before the SSL) was working on the Dev Server beforehand
all packages + dependencies are up-to-date
tl;dr
How do I access the image files from my Parse Server, via Parse-Dashboard or GET request?
A couple methods I tried... Since this was an elaborate process for me, allow me to document the methods I tried to resolve this issue:
The first issue was, do the files exist? If so, where are they stored?
By accessing my parse-dashboard on port 4040, I tried to view the image path via the URL... So I knew it existed somewhere, and I recursively searched my entire server for the file path, but to no avail.
Then with more research I found that any file over 16MB gets converted into a GridFS object i.e. images are stored in my MongoDB. How you access these objects are through a utility called mongofiles.
By running mongofiles -d dbname list I was able to view in a list view all of the images stored on my Parse-Server.
just to ensure the images weren't corrupt...
I also sftp the images over into my local machine, and fortunately I could view them. So the problem was that the images weren't being served correctly...
The next issue was, how come the images aren't being served correctly?
So my parse-dashboard was being served on port 4040, but for some reason, my image file path within their respective URLs were being prefaced with the same port 4040... It turns out that within my Parse-Server config, the parse-server URL was pointing to port 4040, but was being served on ****. By changing my URL back to ****, my images were able to properly render on my parse-dashboard, and I was able to send http requests for the images as well :)
tl;dr make sure your image file path is being served on the same port where your parse-server is being served

Setting source for a script

I'm a bit confused as to how setting a source works for a script inside an HTML file.
Whenever I use a script, I set the source to something along the lines of:
http://localhost:8080/module_name/module.js
However, when I go through the directory of my server, the location is actually something along the lines of:
modules/module_version2.0/module_name/module.js
How is the client accessing the source file when portions of the directory are emitted?
I think what is throwing you off is the configuration and root of the web-server/website versus the file system of the server.
The URL being read by your browser/client will lead the browser/client to the web-server located at localhost:8080 and the web-server will supply the browser/client with information from that website's root directory for any files/pages that are referenced within the html being used via the tags.
The method of configuring this direction/reference to the root or the document tree of the web-server, varies based on OS and web server setup, but is usually held in a files like httpd.conf; which is the file for Apache.
These configuration files can also have different file locations and aliases setup to create relative paths: i.e. you could have pointers for different locations within the web-server's document tree.
The path example from your server is coming from the perspective of a user account logged in to a machine using some method of exploring the systems local file structure. As such the root directory of that system is the lowest location in the file structure and therefore will show the full path of all the files and directories on that machine.
Where as the web-server/website's root directory in most likely located further away from the systems root.
Hope this helps.

Setting moodle online

Good day everyone, I have been trying to put my moodle online so pcs from internet can access it, but until now, no luck at all. (Im using moodle 2.3.2 on Windows Server 2008 and IIS 7).
I tried to configure the moodle file config.php, setting the directive $CFG -> wwwroot = "my-public-ip/moodle". Then, when I access to moodel from the server, I can access it by "http://my-public-ip/moodle", when I try to access via localhost, it sends an error which it is OK.
But the funny part comes when I try to access the server from an outside pc. When I type "http://my-public-ip/moodle" it simply cant "see" the configuration I made to the config.php file (it says: This server cna only be accessed via localhost/moodle) it looks like the outside pcs are either ignoring it, or searching for another configuration file. I dont know what the hell is happening, this is very odd.
Any ideas?? tnx!!!
Change the following file:
lib-->setuplib.php
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 3);
for
Redirect ($CFG->wwwroot, get_string('wwwrootmismatch', 'error', $CFG->wwwroot), 0);
I realise this is an old question, but it's also worth pointing out you may need to also run the database search and replace script, at:
http://my-public-ip/moodle/admin/tool/replace/index.php
as referenced in Method 2 here.
This is required if you change the name of the site once you have installed it. If you were already using Moodle under "localhost", then there will be a number of references to the old localhost address stored in the database that need to be updated to the new IP-based address.
It might be because the http:// part is missing?
$CFG->wwwroot = "my-public-ip/moodle"
should be
$CFG->wwwroot = "http://my-public-ip/moodle"

"URL not found" error at my localhost setup of TYPO3 website.

I have setup TYPO3 successfully on my local server. But I am having problem when clicking on any menu item: It's showing "url not found on server".
When I type in the URL manually into the browser it shows the page. It's only having problems when redirecting after clicking on a page item at any frontend website page.
That might be related to the domain config or RealURL... or both ;)
Do you use RealURL? Or do you use the standard url config?
If links to sub pages look like index.php?id=12345 you are using the standard config.
My guess is that the local DNS ("hosts file") is not configured correctly.
With the hosts file you can simulate how the web site will appear when it's online, hooked up to a "real/global" DNS. (Not quite, but in a nutshell)
So if you set up Typo3 to be reached under http://www.example.com/ you need to tell your local DNS ("hosts file") to route a request to http://www.example.com/ to your local host e.g. http://127.0.0.1/ . In that case your host file needs an entry like so:
127.0.0.1 http://www.example.com/
What Domain do you enter to reach your web site? Where do the links from the menu link to?
If you wanna know mor about the "hosts file" look here:
http://accs-net.com/hosts/how_to_use_hosts.html
If you can log in into the TYPO3 backend (/typo3/) and can access the frondend through /index.php, but not through the generated menu links, then RewriteRules for mod_rewrite don't apply.
Usually TYPO3's installer should detect this configuration and disable RealURL, which is responsible for generating such nice looking URLs (instead of index.php?id=123). It seems like this failed (or you copied everything afterwards without the .htaccess file?).
Make sure that you have TYPO3's .htaccess file in place in the root directory of your installation. If this is the case, make sure that mod_rewrite is enabled in your Apache config.