How to configure the vue project whose nginx file has reached the nginx proxy to access the springboot project in the form of a jar package?

problem description

I wrote a demo to run on Aliyun"s server. The environment on Aliyun uses centos6.9+jdk8+nginx1.12.2 in the image market, but it also pre-installs a tomcat. His original demo should be vue into nginx, and the backend uses tomcat, while my demo uses springboot, packaged in the form of jar package, and can be accessed by the front end running on the server, and the back end can also access it, but the two interactions have not been possible. So I don"t know if the nginx is not configured or for some other reason

the environmental background of the problems and what methods you have tried

1. Do not modify the port of springboot (8081), failed
2. Stop tomcat service, modify springboot port (8080), failed

related codes

/ / Please paste the code text below (do not replace the code with pictures)
/ / this is the default configuration file for nginx
user www www;
worker_processes auto;

error_log / data/wwwlogs/error_nginx.log crit;
pid / var/run/nginx.pid;
worker_rlimit_nofile 51200;

events {
use epoll;
worker_connections 51200;
multi_accept on;
}

http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 432k;
client_max_body_size 1024m;
client_body_buffer_size 10m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
server_tokens off;
tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 464k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;

-sharpGzip Compression
gzip on;
gzip_buffers 168k;
gzip_comp_level 6;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_proxied any;
gzip_vary on;
gzip_types

text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml
text/javascript application/javascript application/x-javascript
text/x-json application/json application/x-web-app-manifest+json
text/css text/plain text/x-component
font/opentype application/x-font-ttf application/vnd.ms-fontobject
image/x-icon;

gzip_disable "MSIE [1-6]. (?!. * SV1)";

-sharpIf you have a lot of static files to serve through Nginx then caching of the files" metadata (not the actual files" contents) can save some latency.
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on;

default

server {

listen 80;
server_name _;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.jsp;
-sharperror_page 404 /404.html;
-sharperror_page 502 /502.html;
location /nginx_status {
  stub_status on;
  access_log off;
  allow 127.0.0.1;
  deny all;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
  expires 30d;
  access_log off;
}
location ~ .*\.(js|css)?$ {
  expires 7d;
  access_log off;
}
location ~ {
  proxy_pass http://127.0.0.1:8080;
  include proxy.conf;
}
location ~ /\.ht {
  deny all;
}

}

vhost

include vhost/*.conf;
}

what result do you expect? What is the error message actually seen?

the normal result should be interactive. Nginx proxy vue has not been tried locally to access the backend. Common functions such as login, browser error
OPTIONS http://127.0.0.1:8081/login net::ERR_CONNECTION_REFUSED

Jul.06,2022

where your front-end code is deployed is not clear. The wrong guess reported through the browser is that the address of your front-end application calling the interface is 127.0.0.1.
127.0.0.1 refers to your local computer. If you deploy on Aliyun in the background, this address can't be 127.0.0.1 anyway.
so the problem with you should be that there is something wrong with the address where your front end calls api.


the front-end interface address is accessed on your browser. The interface address configured in your vue project is 127.0.0.1. Use the browser to access the front-end project, and the browser will access 127.0.0.1 on the client machine.

The

browser finds that the address of the front-end project, such as https://, your domain name is inconsistent with the access address of the interface http://127.0.0.1, so cross-domain problems occur. This means that the browser will first send a pre-check request to your interface address ( options ). Because the request for http://127.0.0.1 is not accessible on the machine where the browser is located, an error of net::ERR_CONNECTION_REFUSED occurs.

The solution is simple: configure the interface path in your front-end project to the interface address provided by the springboot service on your Ali cloud. Usually https:// your domain name / api . Make sure that your front-end project access address and your springboot interface service address are the same in the domain name and port number, otherwise there will still be cross-domain problems.

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-1eb0a60-480b3.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-1eb0a60-480b3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?