Missing files when deploying react-boilerplate project to IIS - iis

I've successfully generated the production files and run from the node prod server (built into react-boilerplate). When I run the project from the IIS-configured URL, http://localhost/abc/, I get console errors:
GET http://localhost/main.21e300b8d1fb516da3f2.js and
GET http://localhost/main.7298ab25765cc3b7f65141e9b8a880ff.css
The path appears to be pointing to the root of localhost and doesn't seem to include "/abc".
I've set up my webpack config like so:
module.exports = (options) => ({
entry: options.entry,
output: Object.assign({
path: path.resolve(process.cwd()),
publicPath: '/',
}, options.output),...
Is there a setting in my Webpack config I'm missing? Thanks for any help.

It sounds like you've set up your site in IIS as a virtual directory within the IIS site pointing to localhost. The issue here is that any references to / in your site will translate to the root of your site, not the virtual directory.
Option 1 is to have Default Website point to your applicaiton (instead of the virtual directory).
Option 2 is to create a whole new site in IIS and bind it to another port (or port 80 with a host header and a HOSTS entry).
Looking at your config, what happens if you set publicPath to /abc instead of /?

Related

.Net Core not handling requests when defined in subdomain folder

I have a Linux Centos v7.9 with Apache installed. I published my web project to the server. For the backend I set it on port 90 and created a configuration file for apache with proxy server (to redirect to another port 31031, where .net 5 is listening and handling the requests. This works fine when I request my server ip with port 90. But when I wanted to set the backend as subdomain like api.domain.com and modified the configuration file, .net 5 is not handling the request anymore. When I request api.domain.com I see folder structure. What did I miss?
Here is the .conf file:
Service file:
Subdomain from cpanel:
Thanks.

Add non-docker service to traefik v2 - site resources missing

Question update below!
I have set up traefik in the last days, it seems to work great for docker containers. What does not work is setting up a non-docker backend. I have a netdata dashboard running (https://github.com/netdata/netdata) on port 19999 on the host.
I have defined a file provider:
[providers.file]
directory = "/home/myname/traefik"
filename = "providers.toml"
watch = true
Where I defined the service and router for my netdata dashboard:
[http.routers]
[http.routers.netdata]
service = "netdata"
middlewares = ["replacepath"]
rule = "Host(`my.host.name`) && Path(`/netdata`)"
[http.middlewares]
[http.middlewares.replacepath.replacePath]
path = "/"
[http.services]
[http.services.netdata]
[http.services.netdata.loadBalancer]
[[http.services.netdata.loadBalancer.servers]]
url = "http://192.168.178.60:19999/" ---> my server local ip
I use replacepath to strip the path so I don't end up one directory further down, which is not existing.
However when I visit http://my.host.name/netdata it serves me only raw html by the looks of it, I get 404s for .css and .js content.
What do I have to do to get all files in the website directory delivered? I feel like there is an easy solution to this which I can't see right now...
I found several tutorials using older traefik versions, where they use frontends and backends, to my understanding these are being replaced by routers, middlewares and services.
I tried using "http://localhost:19999" instead of my local ip, with no success (results in a bad gateway error)
I also tried setting the traefik container to the network "host" because the containers should be isolated from the rest of the host, so traefik cannot communicate with the netdata server, but as I said I get at least part of the website, so this can't be the issue?
Update #1, 30 Jan 20:
After some more tries and a failed attempt to make it work with nginx I realized that not the proxy itself is the problem here. I noticed that whatever service I run at root level (so, not path rules in traefik, or location / in nginx) it works, but everything else which gets a path/location is broken or not working at all. One service I wanted to proxy via a route is a dashboard from my homebridge (https://github.com/nfarina/homebridge) - but it seems like Angular is having troubles with custom paths. Same problem with my netdata dashboard or my onionbox status site. I am leaving this question open, maybe someone finds a (hacky) way of making it work.
You must use "PathPrefix" on router and "replacePathRegex" on middleware.
Try this way... its work for me:
[http]
[http.services]
[http.services.netdata]
[http.services.netdata.loadBalancer]
[[http.services.netdata.loadBalancer.servers]]
url = "http://172.24.0.1:19999"
[http.middlewares]
[http.middlewares.rem_subfolder]
[http.middlewares.rem_subfolder.replacePathRegex]
regex = "/netdata/(.*)"
replacement = "/$1"
[http.routers]
[http.routers.netdata]
rule = "PathPrefix(`/netdata/`)"
entrypoints = [
"web",
"websecure"
]
middlewares = [
"rem_subfolder"
]
service = "netdata"
Run the following command to get your host ip (default route), and set at "url" from service.
docker exec -it traefik ip route
Remember to change bind to = * to bind to = 172.24.0.1 at netdata.conf, to make it accessible only from traefik.

Namecheap: Node JS Express App - App Route return 404 not found

Trying to get Simple Express Application up using NameCheap Shared Hosting.
I have set up my Node JS application as Described here NodeJS NameCheap Docs
Current Setup:
Application Root: url.com
Application URL: url.com
Application Startup File: server.js
I have ran NPM Install using the button provided
I have tried loading the URL http://url.com/hello Expecting Hello World to displayed in the Page.
var express = require("express");
var app = express();
const port = 3001;
app.set("port", port);
app.get("/hello", function(req, res) {
res.send("hello world");
});
app.listen(app.get("port"), () =>
console.log("Started listening on %s", app.get("port"))
);
The results I am getting when navigating to http://url.com/hello:
Not Found
The requested URL /index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Namecheap only tells you how to configure the nodejs app however their hosting is based on cPanel which requires you configure the webserver (apache generally). Once you get an application running there’s a special button to register it for the apache configuration aka let it run from your domain. I don’t know the steps by heart but you should ask NC support to direct you to their documentation for configuring apache to run a nodejs app you configured.
If they do not link an article from their knowledge base use this link: https://confluence1.cpanel.net/plugins/servlet/mobile?contentId=17190639#content/view/17190639
Basically what you need now is to configure cPanel or ssh into your server and test your app locally. There’s a number of things that could cause your issues like incorrect apache configuration (your default port 80 is looking for php app), port not open/firewalled, application not registered - and all of this is cPanel specific.
To make sure you are reading the correct document check in namecheap cpanel for the docs button and review all the above. It should be obvious what needs configured - your nodejs code is probably not the cause here
In my case, it was the problem with .htaccess file. Adding the following rules in my .htaccess file present in the website's public directory helped me:
# CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/<user>/<your_nodejs_app_folder>"
PassengerBaseURI "/."
PassengerNodejs "/home/<user>/nodevenv/<nodejs_app>/<version>/bin/node"
PassengerAppType node
PassengerStartupFile <startup_script>.js
# CLOUDLINUX PASSENGER CONFIGURATION END
Make the required changes in the above rules before pasting them in your .htaccess file. Also, just in case, make sure the port you are using is open, via customer support.

IIS Express Site not loading, however 127.0.0.1 find IIS

Struggling to get my site to work within IIS Express on Windows 7. (Umbraco) Works fine at work on Server 2012 R2.
IIS Settings
Sitename: umbraco.local
Application Pool: umbraco.local
Physical path (to the root folder)
App pool set at .Net v4.0
hosts file in System32 includes 127.0.0.1 umbraco.local
127.0.0.1 routes to the IIS7 page, as does localhost
umbraco.local can not be found
The root folder permissions is set to Everyone and full access..
any ideas
thanks

How to set up local subdomains for Node.js app

I am running an express app on node.js. The app uses the express-subdomain module to help handle routes for two different subdomains (sub1.example.com and sub2.example.com). I'm hosting the app on AWS Elastic Beanstalk. In my production environment, everything works great. But on my local machine, I cannot get this to work. I tried adding the subdomains to my host file 127.0.0.1 localhost sub1.localhost sub2.localhost. Although that allows me to prepend a subdomain to localhost, the module doesn't recognize this as a valid subdomain, and therefor searches for subdomain routes in my root routes.
In main.js:
var routes = require('./routes/index')(passport);
var sub1_routes = require('./routes/sub1')(passport);
var sub2_routes = require('./routes/sub2')(passport);
app.use(subdomain('sub1', sub1_routes));
app.use(subdomain('sub2', sub1_routes));
app.use('/', routes);
I need to be able to handle this locally. It takes to much time to push a small change to AWS test, iterate, etc.
I'm the author of the module :)
For each new subdomain you wish to test locally you must add into your /etc/hosts file. So for example:
localhost is:
127.0.0.1 localhost
a new subdomain would be..
127.0.0.1 sub1.localhost
and another..
127.0.0.1 sub2.localhost
Check out what I have done in the tests.
I had same exact problem and I found a simple solution. Instead of writing sub1.localhost try replacing localhost with lvh.me this is a domain that always resolves to localhost and now whenever you write sub1.lvh.me even though a port like sub1.lvh.me:3000 it will still work.
There is an awesome website, which someone hosted for all of us.
localtest.me
All requests will be routed to 127.0.0.1, including subdomains.
e.g something.localtest.me:3000
will resolve to 127.0.0.1:3000
but, for example, in your Express app, if you do
app.get('*', (req, res) => {
console.log(req.subdomains); // [ something ]
});
you'll get your subdomain
on Ubuntu
For creating subdomains for localhost you just need to follow 2 simple steps.
Open your terminal by pressing CTRL + ALT + T then run the following commands:
sudo vi hosts
sudo -i gedit /etc/hosts # to edit /etc/hosts file
Once you run 2nd command /etc/hosts file will open and now this is the place where you need to define subdomains.
Example: localhost is:
127.0.0.1 //our localhost
define new subdomain:
127.0.0.1 example.localhost # first
and another..
127.0.0.1 demo.localhost #second
that's it. Hope this was helpful.

Resources