I have problems when refresh pages in my react project, for that I'm trying to configure my Nginx, because in my localhost works ok.
An alternative option to networkd is NetworkManager, if the interface is managed by the NetworkManager. If you looked at the netplan config file of the Ubuntu 18.04 desktop, the renderer option is set to NetworkManager, because in a graphical desktop environment interfaces are managed by the NetworkManager. Next, we start the interface configuration.
I'm new in Nginx and I've tried for more than 2 hours without success.
Context:
I have 2 projects in React with React route, then I need to configure for both but I'm trying first configure one.
My first project is in
/var/www/html/app
and my second project/var/www/html/dashboard
, both works well, withhttp://MY_IP/app
andhttp://MY_IP/dashboard
I opened the the file
/etc/nginx/sites-enabled/default
(I removed a lot of commets):
And only I changed:
try_files $uri $uri/ =404; -> try_files $uri $uri/ index.html;
root /var/www/html; -> root /var/www/html/app;
and After in console: sudo systemctl restart nginx
Problem:
When I made that changes, nothing happens and the page http://MY_IP/app
is blank.
I tried many variants, but when I refresh http://MY_IP/app/sale
continue with error and route doesn't work.
what I am doing wrong?, That is the correct file to modify?, any suggestion will be amazing.
Note:
- My nginx is in EC2(aws)
Thanks.
1 Answer
Not the answer you're looking for? Browse other questions tagged ubuntunginxreact-router or ask your own question.
I have used Ubuntu since Ubuntu 8.10; today I'm working with Ubuntu 12.04 Server.
I am having difficulty keeping static routes on booting. I would usually put the route commands
in /etc/rc.local
or I would create a file (named routes
) inside the directory /etc/network/if-up/
, but I notice that on Ubuntu 12.04 it isn't working.
If I type the commands in the shell, they work, but the same commands don't work when they are in the specified file.
I already tried to change the file name to other names thinking that my file name (routes
) could be erroneous in Ubuntu 12.04, but that also did not work.
I notice also that command /sbin/ifconfig
works, less the /sbin/route
.
What changed in network set-up?
How can I define static routes on Ubuntu 12.04?
5 Answers
You can put static routes in /etc/network/interfaces
:
I found very often that the correct place to define a static route is in /etc/network/interfaces, it is ok if you are going to globally restart the network with /etc/init.d/networking restart for example. But if you are going to use ifdown and ifup to individually shutdown an interface, ifup will end with the error:
Because of it tries to define a route but it is already defined. The interface will be up anyway but, ifup will not update /run/network/ifstate so next time you will us ifdown you will not able to do it unless you use the --force flag.
To make ifup to continue configuring even if routes are already defined, you can use this format when defining routes in /etc/network/interfaces
This way you will have the warning in the output but the interface configuration will be completed
You can try this (add it to /etc/network/interfaces
), this is almost complete way for setting routes:
There is a package ifupdown-extra avaible in Ubuntu.
It provides automatic scripts (installed in /etc/network/*/
), one of which is used to add static routes.
The configuration file for this is /etc/network/routes
The top of this config file has a good description:
This configuration file is read by the static-routes if-updown script and the /etc/init.d/networking-routes script to setup a list of routes associated either with a given interface or global routes.
An example route I use is:
what worked for us was
i used to run on a Mac:
but on a ubuntu the 'gw' between IPs and the last 'netmask' part was missing (also -n not required on ubuntu)