-
설정 파일 수정
sudo vi /etc/nginx/sites-available/default# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } location /api/ { rewrite ^/api(/.*)$ $1 break; # url에서 api 뒤에 있는 URL을 전부 그대로 사용. # ip/api/blahblah로 들어온 요청은 ip/blahblah로 Spring에 전달됩니다. proxy_pass http://localhost:8080; }해당 내용으로 수정하고
sudo service nginx restart실행spring에 보내는 요청이
/api를 통해서 80포트에서 정상적으로 전달되는지 확인.
이렇게 설정하면 api라고 경로를 지정해야 8080포트로 요청이 전달됩니다.
물론 api는 Spring에서 지정해주지 않아도, rewrite로 경로가 지정됩니다.
/var/www/html