The first stage: modify the initial path access in the framework
The default access address was modified. Because I was not familiar with the configuration of the framework at that time, and there was no architecture related documentation, the attempt failed. Although the modification is completed, you can directly access the home page of the portal according to the domain name, but the back-end business can’t be accessed normally. I doubt that I have changed something. If you are familiar with ruoyi architecture and have completed this modification method, please give me more advice.
The second stage: using nginx to separate the front and back of the portal
The portal page of the website uses static HTML pages, and then the data request is implemented through Ajax. Configure two domain names to resolve to the server where the service is located, the first level domain name to access the portal related functions, and the second level domain name to access the background management page. Two schemes are prepared. One is to simply use HTML and Ajax. First, nginx forwards the request to the HTML page according to the domain name, and then uses Ajax to get the data from the background when the page is initialized. The second is to use Vue, which is actually an optimization on the first one. Through the loop contained in Vue and other tags, it is easy to load and echo the data, but When the page is loaded, the unresolved Vue variables will be displayed first. The experience is very poor, so this method is abandoned. I think the efficiency and page rendering experience of the first method will be very poor, so in the case of other implementation methods, I will not consider this method for the moment. In fact, these two methods can achieve basic requirements such as data loading.
The third stage: directly using the page of the original project
At the beginning, I didn’t think of this method, but later when I modified the second method, I suddenly thought that according to the previous project experience, I can do redirection jump in nginx, so I began to try this way. The basic idea is: configure two servers in nginx to monitor port 80, and judge which server to enter according to the domain name. When the access is a first-class domain name, judge the website related business, that is, judge whether the URL contains only the domain name. If it contains only the domain name, then redirect the request to the path of the portal home page. For other requests, handle them normally .
No more nonsense. Go directly to nginx configuration
server {
listen 80;
server_name ywgl.*****.com;
index index.html;
set $ht_server 127.0.0.1:8080;
location /{
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://$ht_server;
}
}
server {
listen 80;
server_name www.******.com;
index index.html;
set $mh_server 127.0.0.1:8888;
location /{
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
if ($request_uri ~* "^/$") {
rewrite ^/(.*)$ http://www.******.com/home/index?; # Preventing multiple redirects
}
proxy_pass http://$mh_server ;
}
}
explain:
$request_ Uri ~ * “^/$” this condition is to determine whether the access request is www. * * *. Com, not www. * * *. COM/*/*, because even if the access request is www. * * *. Com, nginx will send a $request_ What URI gets will still contain a ‘/’.
Finally, if you have any ideas, welcome to exchange.
Read More:
- Nginx Startup Error: Job for nginx.service failed because the control process exited with error code
- Restart and stop of nginx in Linux service
- [Solved] nginx: [error] open() “/usr/local/nginx/nginx.pid” failed (2: No such file or directory)
- Nginx Startup Error: “/var/run/nginx/nginx.pid” failed” [How to Solve]
- Nginx Error: Swap file “/etc/nginx/.nginx.conf.swp“ already exists
- Nginx Error: nginx: [emerg] the “ssl“ parameter requires ngx_http_ssl_module in /project/api/nginx.conf:
- Nginx error: nginx: [error] invalid PID number ““ in “/run/nginx.pid“
- [Nginx] solution: it can’t be accessed on the background API interface after HTTPS (access the specified port through the domain name)
- [Solved] Nginx Restart Error: /run/nginx.pid failed (2: No such file or directory)
- Common configuration methods of nginx
- tuxedo Compile Background Common Error [How to Fix]
- Solve the problem of 404 Not Found error in nginx accessing dynamic interface
- [Solved] Linux Service Start Error: *.service: Main process exited, code=exited, status=203/EXEC
- How to Fix No default.conf file in conf.d after Installing Nginx
- Nginx Reverse Proxy 426 Error [How to Fix]
- Nginx configuration 80 can be accessed by forcing jump 443 or not
- Nginx routes and forwards according to the URL and cuts the URL
- [Solved] Nginx cannot access pictures on FTP Error: Whitelabel error page
- Linux Install Docker Error: Failed to restart docker.service: Unit docker.service not found.
- nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)