Force SSL for hosting - ssl

I have an angular app hosted on Parse.com using their Javascript SDK. I want to force the users to access via SSL.
I have no actual cloud code other than the documentation suggested code to redirect to SSL.
cloud/main.js
require('cloud/app.js');
cloud/app.js
var express = require('express');
var app = express();
var parseExpressHttpsRedirect = require('parse-express-https-redirect');
app.use(parseExpressHttpsRedirect());
app.listen();
When I nav to http://myapp.parseapp.com index.html is delivered and no redirect is made.
I could write some javascript to redirect but users could opt out of it so its not really a solution.
Any help will be greatly appreciated.

What's happening here is that public/index.html exists and is served statically by the web server. Your express code isn't being run because this file exists on the file system.
If you go to http://myapp.parseapp.com/some-page-doesnt-exist.html however then you'll be redirected to HTTPS because the request is passed to your express code.
The solution is to delete public/index.html and to have all HTTP requests go through express. Then you can serve index.html using express.
https://parse.com/docs/hosting_guide#webapp

Related

Vue : 404 page not found after refresh page

I have Vue website works correctlly on localhost ,after I build it and uploaded it on server ,the routes works fine but have two problems :
1- when I click on route and the page open ,then if i refresh the page it gives me an error 404 page not found.
2- the connect to api by axios don't work?
How can I solve them?
The problem is your web server. Make sure that your web server (Apache, Nginx, Express etc.) always points to the Index.html.
Your web server is not aware that the SPA should do the routing.

Is there a way to redirect a NuxtJs application using Express server?

I have a NuxtJs application initialized with Express server using npx create-nuxt-app <project-name>. It is set for server-side rendering.
Express has access to NuxtJs middleware like so. ( Which comes by default when Nuxt app is created )
app.use(nuxt.render)
Now I have created a different route file in server side that handles API routes. This route works as I can access data using Axios. I have added this route right before the above code, like this. ( API routes don't work if it is added after )
app.use('/api', apiRoutes)
app.use(nuxt.render)
There is a route where, after some operation, I need to redirect the application to another page. I tried using res.redirect('/some-route'), which is an Express way for redirection but that didn't work.
Am I missing something here? Is there some other way we do redirection from server side in Nuxt application that I'm totally unaware of?
Finally found the way to redirect from the back-end.
res.writeHead(301, { Location: url })
res.end()
Here is the link to Nuxt GitHub issue comment for detailed example using server middleware.
Alternatively, you could respond with desired value to the font-end and based on the value received, you can re-direct from the front-end.

Blazor server side behind reverse proxy 404

I have a blazor server-side app hosted on IIS behind a reverse proxy (using ARR).
I have tried everything I can think of, but I keep getting 404 on
_framework/blazor.server.js
My base href is is set to "/subsite/":
<base href="/subsite/" />
and all my src values are relative like this:
<script src="_framework/blazor.server.js"></script>
<script src="_content/BlazorInputFile/inputfile.js"></script>
<script src="animations.js"></script>
Every other script ref loads fine, EVEN the _content data, but not the blazor.server.js.
I tried the old PathBase trick for MVC apps as well with no success:
if (!env.IsDevelopment()) {
app.Use((context, next) => {
context.Request.PathBase = new PathString("/subsite");
return next();
});
}
Can anyone tell me how to make Blazor realize where to put the blazor.server.js in a reverse proxy scenario?
Did you try the UsePathBase ?
app.UsePathBase("/subsite");
Here is my test result
Please check this article for more
https://www.billbogaiv.com/posts/net-core-hosted-on-subdirectories-in-nginx
From docs.
Rewrite URLs for correct routing
Routing requests for page components in a Blazor WebAssembly app isn't as straightforward as routing requests in a Blazor Server, hosted app. Consider a Blazor WebAssembly app with two components:
Main.razor – Loads at the root of the app and contains a link to the About component (href="About").
About.razor – About component.
When the app's default document is requested using the browser's address
bar (for example, https://www.contoso.com/):
The browser makes a request.
The default page is returned, which is usually index.html.
index.html bootstraps the app.
Blazor's router loads, and the Razor Main component is rendered.
In the Main page, selecting the link to the About component works on the client because the Blazor router stops the browser from making a request on the Internet to www.contoso.com for About and serves the rendered About component itself. All of the requests for internal endpoints within the Blazor WebAssembly app work the same way: Requests don't trigger browser-based requests to server-hosted resources on the Internet. The router handles the requests internally.
If a request is made using the browser's address bar for www.contoso.com/About, the request fails. No such resource exists on the app's Internet host, so a 404 - Not Found response is returned.
Because browsers make requests to Internet-based hosts for client-side pages, web servers and hosting services must rewrite all requests for resources not physically on the server to the index.html page. When index.html is returned, the app's Blazor router takes over and responds with the correct resource.
When deploying to an IIS server, you can use the URL Rewrite Module with the app's published web.config file. For more information, see the IIS section.
Maybe you could try to enable the forward proxy in IIS manager->server node->application request routing cache->proxy->enable.
If you only have one website, you could just add the website to ARR server farm and then it will create the routing rule automatically. It will be convenient to monitor the back-end server with health check.
Is this ARR warning causing my 404?

Steps to redirect Application URL to Custom URL

i have IHS 7 installed on an AIX system and its pointing to Application Server . now my requirement is if Application is not accessible or if we are working on the Application it self then whoever access the URL, it redirects to a custom page on the webserver that Application is under construction .
for example url is https://my.Application.com:8089/application if anyone hits this URL then this URL is redirected to custom URL on same webserver https://my.webserver
i have configured a proxy on IHS httpd.conf but it is not working
The good practice in such case is to create two config files and one maintenance page. When your app server do not work you should restart http server with config file which point to the maintenance page.

Is it possible to make a cross domain request from https to http in IE?

We are trying to access a local self-hosted WCF service from the browser.
The WCF service is located at http://localhost/myWcf.
The browser is running a website which is located at https://some.www.com.
We have enabled CORS and added CORS header to the hosted WCF. Access to the WCF service is done using jQuery’s $.ajax call. All browsers are working fine when not using SSL and we’re getting to the “success” callback.
When switching to SSL, IE is the only one that fails to make the request – “Access is denied”. We moved the website to the trusted sites section and basically allowed everything there and still no go. We’re using IE11/10 and we've tried previous versions through its emulator. None of them allows us to make that request.
We can address a picture that located in http from https like this:
<img src="http://asdasd">
but we try to use javascript it fails:
var img = new Image();
img.src="http://asdasd";
What are we missing? Is it really impossible to make a cross domain request from https to http in IE?
Check jsonp:
var script = document.createElement('script');
script.id = 'dynScript';
script.type='text/javascript';
script.src = 'http://localhost/myWcf';
document.getElementsByTagName('head')[0].appendChild(script);
JSONP is a great away to get around cross-domain scripting errors.