I would like to ask how to configure nginx, on the server of the linux system. I want to access my packaged vue project on the external network. How to operate it?

Hello, seniors. I bought a CVM in Aliyun. I want to throw my packaged vue project on it and use the public network to access it. I can access it normally when I configure nginx, on my own window computer! But throwing it into the server of the linux system will die! I would like to ask how to configure ah, is not the conf configuration file to be greatly changed!??

this is my window computer, configuration, is OK!
this is the conf configuration of nginx on window system
clipboard.png

after opening nginx, open port 8080, all normal, the address of the request interface is also normal, and cross-domain errors will not be reported.

but put the dist folder and this configuration file on the cloud server of the linux system, and it won"t work! Keep reporting 404 error, can"t find it!?

I would like to ask how the server in the linux system should configure the configuration file of nginx. I hope experienced seniors can give me some advice. Excuse me!

Mar.03,2021

server {
         listen 80 default_server;
         listen [::]:80 default_server;

         root < root-path or link >;
         index index.html;

         server_name < server-host >;

         location / {
                try_files $uri $uri/ /index.html =404;
                add_header cache-control max-age=86400;
         }
}

to use nginx to serve a static page, just a few lines of configuration is enough.

generally speaking, the simple steps for building a linux station are:

  • first create a soft link to your static resource directory, such as / var/www/foo.com-> root-path , so that the root in your configuration file can just fill in the soft link, instead of filling in the resource address
  • directly.
  • then create a new configuration file under the sites configuration path of nginx, generally and your domain name object, such as / etc/nginx/sites-available/foo.com , then copy the above configuration, and then create a soft link to / etc/nginx/sites-enabled/foo.com to / etc/nginx/sites-available/foo.com .
  • then check it with nginx, such as sudo nginx-t . If there are any errors in the configuration file, you will be prompted
  • . Restart the server after
  • , sudo systemctl restart nginx

the above commands are slightly different for different Linux systems, but they are more or less the same. using more soft links can save you the repetitive work of modifying configuration files.

in addition, if the open ports of the public network are 80 and 443j8080, you need to specify the port.

if this doesn't work, try to check that the firewall has opened the port you need to access, and command sudo ufw status

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1eac721-20d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1eac721-20d6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?