In this article we will learn how to expose Spring Boot web application with the help of NGINX reverse proxy.
Install NGINX
Let’s begin with installation of NGINX, for this tutorial we will be using Ubuntu linux. We will use NGINX official distribution and to get the relevant binaries for our Ubuntu system, we will first check the Codename of our Ubuntu installation. Run following command to get the Codename of Ubuntu Instalation.
lsb_release -a
The output of this command will be something like following.
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
In this case the code name is xenial.
Now we will add the link to NGINX official repository to sources.list
of ubuntu. Open /etc/apt/sources.list
using your favourite text editor, for this tutorial I will be using nano
.
sudo nano /etc/apt/sources.list
Add following line to the end of sources.list
file, pelase remember to replace the xenial with Codename of your Ubuntu release.
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx
Save and exit the editor, for nano press Ctrl + O to save the file and Ctrl + X to exit the editor.
Run following command to download signing key for NGINX repository.
sudo wget http://nginx.org/keys/nginx_signing.key
Add the repository signing key (downloaded in previous step) to apt.
sudo apt-key add nginx_signing.key
If the command was successful it will print OK on screen.
OK
Now update the apt package manager index using the apt update
command.
sudo apt update
Finally we will install the NGINX using apt package manager as following.
sudo apt install nginx
Run following command to check if NGINX was successfully installed.
nginx -v
Above command will print the version string of installed NGINX server.
nginx version: nginx/1.19.2
Run following command to enable NGINX service.
sudo systemctl enable nginx
Output of this command will be something like.
Synchronizing state of nginx.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable nginx
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
NGINX has been installed successfully on your system, you can use following commands to start or stop NGINX service.
sudo service nginx start
sudo service nginx stop
Run following command to check the current status of NGINX servcie.
sudo service nginx status
This will print current status of NGINX service as following.
● nginx.service - nginx - high performance web server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-09-24 19:49:40 UTC; 5s ago
Docs: http://nginx.org/en/docs/
Process: 6753 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
Main PID: 6755 (nginx)
Tasks: 2
Memory: 1.3M
CPU: 7ms
CGroup: /system.slice/nginx.service
├─6755 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.con
└─6756 nginx: worker process
Sep 24 19:49:40 ams-dev systemd[1]: Starting nginx - high performance web server...
Sep 24 19:49:40 ams-dev systemd[1]: Started nginx - high performance web server.
To proceed with following steps you will have to setup your spring boot application as service. If you are not familiar with this process, pelase following read this article.
NGINX Configuration
In context of this article we will assume Spring Boot application is up and running on HTTP port 8080.
We will start with creating a configuration file for our new virtual server. Remember to replace the name of the conf
file "testserver"
accordingly.
sudo nano /etc/nginx/conf.d/testserver.conf
Copy following configuration to testserver.conf
.
server {
listen 80;
listen [::]:80;
server_name testserver.com;
location / {
proxy_pass http://localhost:8080/;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
65 thoughts on “Spring Boot Deployment with NGINX Proxy”
Leave a Reply
You must be logged in to post a comment.
This design is steller! You certainly know how to keep a reader amused. Eleanore Lothario Binah
If you wish for to improve your experience simply keep visiting this web site and be updated with the latest information posted here. Coralie Alisander Butch
Very informative post. Much thanks again. Really Great. Cammy Em Khorma
Way cool! Some very valid points! I appreciate you writing this write-up and also the rest of the website is extremely good. Rebecka Dennison Humberto
There is definately a great deal to know about this subject. I like all the points you have made. Nanice Dennet Aluin
Some genuinely nice and utilitarian information on this site, also I think the pattern has wonderful features. Ema Fields Cohligan
Very good post. I definitely appreciate this site. Natasha Husein Katonah
I say Thank You because of your caring about the accuracy of your content, and thus those who read it. Liuka Torrance Berrie
Hello mates, its wonderful paragraph regarding teachingand entirely defined, keep it up all the time. Sibeal Barnaby Jamesy
Pretty! This has been a really wonderful article. Thanks for supplying this info. Stevena Osbourne Rotow
Check below, are some absolutely unrelated web-sites to ours, even so, they may be most trustworthy sources that we use. Kissie Jeremy Novelia
Very couple of internet websites that come about to be in depth beneath, from our point of view are undoubtedly very well really worth checking out. Mureil Casey Babita
This is a dialect right spellbinding post. Keep them coming. Margalit Malcolm Berners
I am genuinely thankful to the owner of this site who has shared this fantastic article at at this time. Edita Borden Decamp Prudi Robinet Coumas
Excellent article. I am experiencing a few of these issues as well.. Celka Iorgo Tengdin
I think you have a typo, the docs seem to state that ExpressRoute premium is required, not standard. If it only requires standard, that would be awesome. Karie Horton Licha
Thanks, Marjorie. Always happy to have you come along! Charmaine Baudoin Cathie
These were some very valid and well placed thoughts. Adding to your last part, I want to continue that part. I do think that she did make a new body for herself with no powers because at the end the watch had no power and when the MC reunites with Cro at the end, it never stated that the watch began to tick again so she may have come back as a human with no powers and thereby no power in the watch anymore Agata Braden Docilu
hai maam Marifel Dungo pyde po bang maka beli nang reviewer ta saka answer key?? Madeline Damon Aronow
I plan to take CPP, 65 or later. Currently retired, and live comfortably on a company pension. Using tax table strategy to draw down the registered investments. Hate paying tax! Have a few health issues, so shall see how that plays out and will adjust accordingly. Lacee Vale Edita
Looking forward to reading more. Great post. Thanks Again. Really Cool. Kaylil Gabi Cobby
Thanks-a-mundo for the post. Really looking forward to read more. Want more. Layney Gardiner Tucker
Released my friend. But others have come home this season in her place. For sure Doug, they are GREAT eating. Meris Martin Codie
I think the problem for me is the energistically benchmark focused growth strategies via superior supply chains. Compellingly reintermediate mission-critical potentialities whereas cross functional scenarios. Phosfluorescently re-engineer distributed processes without standardized supply chains. Quickly initiate efficient initiatives without wireless web services. Interactively underwhelm turnkey initiatives before high-payoff relationships. Denise Byrom Goff
i discover this extremely embarrasing but the product in my site link definitely served Natasha Dennet Salaidh
I precisely needed to appreciate you once again. I am not sure the things that I might have gone through in the absence of the entire opinions documented by you directly on such a industry. It had been a very frightening difficulty in my circumstances, however , looking at the skilled manner you managed that made me to jump over fulfillment. I am happier for this help and even hope you find out what a great job you are doing instructing other individuals through the use of your site. I know that you have never encountered all of us. Mellisent Dwight Lam
You made some good points there. I looked on the web for more info about the issue and found most individuals will go along with your views on this website. Angele Goraud Kellia
I simply wanted to type a simple comment so as to appreciate you for the great solutions you are sharing here. My rather long internet lookup has at the end been honored with high-quality knowledge to share with my good friends. I would mention that most of us readers actually are definitely blessed to live in a good site with many special people with very beneficial basics. I feel rather privileged to have come across your entire webpage and look forward to some more awesome minutes reading here. Thank you once again for all the details. Annabella Norbie Hurst
You could definitely see your expertise in the article you write. Amandi Adolphe Lough
Ah, that makes sense. I was right, just had my facts ordered wrongly. Keri Leonardo Chery
As a Newbie, I am permanently searching online for articles that can aid me. Thank you Jackqueline Garv Elurd
hi!,I really like your writing so much! proportion we communicate extra approximately your article on AOL? I require a specialist on this area to unravel my problem. May be that is you! Taking a look forward to look you. Sybyl Herbie Wenn
Publishing unique articles can be easier than most people think. Lolita Derk Eberly
I got this web page from my pal who told me regarding this web page and now this time I am visiting this site and reading very informative content at this time.| Kalila Georgy Mears
You have made some good points there. I looked on the web for more information about the issue and found most individuals will go along with your views on this web site. Anett Mel Statis
First mover advantage stealth crowdsource angel investor backing accelerator seed round startup client freemium burn rate supply chain infrastructure success. Infographic success growth hacking traction startup pitch twitter hackathon launch party niche market strategy burn rate infrastructure. Jody Garald Adrea
Sed facilisis nibh eu lobortis consequat. Mauris et velit molestie, auctor eros suscipit, tempor vela neque, hendrerit vel pulvinar ut, ornare nec sapien. Suspendisse bibendum id molestie felis eget. Lorem ipsum dolor sit amet, est te posidonium omittantur, eu eum noster alienum graecis vix. Joelynn Torin Aguste
I have been browsing online more than 2 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.| Bette Far Bertle
I as well as my guys have been going through the good items found on your website and so instantly came up with a horrible feeling I had not thanked the website owner for those strategies. These young boys are actually certainly happy to learn all of them and have sincerely been having fun with these things. Appreciate your getting well kind as well as for making a choice on these kinds of perfect resources most people are really desperate to understand about. Our sincere regret for not expressing gratitude to you sooner. Meridel Giffie Woodman
Do you have a spam problem on this site; I also am a blogger, and I was curious about your situation; many of us have created some nice procedures and we are looking to swap methods with others, be sure to shoot me an e-mail if interested. Deerdre Durand Bianca
One other issue is when you are in a predicament where you do not possess a cosigner then you may genuinely wish to try to wear out all of your financial aid options. You will discover many awards and other free college funding that will present you with money to help with college expenses. Thank you for the post. Hedwiga Gery Natalee
Thanks-a-mundo for the blog post. Thanks Again. Really Cool. Ardyce Bruis Rabassa
Loved this blog the first time I read it and love it even more!! Jillene Abbey Pettit
Incredible story there. What happened after? Take care! Misti Trev Kowal
I am in fact grateful to the owner of this web page who has shared this wonderful post at at this time. Bessy Thane Rhynd
Thank you for the sensible critique. Me and my cousin were just preparing to do some research on this. We grabbed a book from our local library but I think I learned better from this post. I am very glad to see such magnificent info being shared freely out there.. Kaylee Herschel Sheryle
putas,escorts,escort,escorts independientes,escorts capital federal,escorts argentina,escort vip,escorts buenos aires Ophelie Ezechiel Schreiber
I like it when individuals get together and share thoughts. Great site, keep it up! Briney Farlay Ingar
Demasiado valioso tu aporte y estoy de acuerdo contigo, es un escenario bastante complejo para denominarlo moda. Harriett Ambrosi Alodie
What a pleasure to find someone who identifies the issues so clearly Dasha Kliment Flore
Wow! Thank you! I continually needed to write on my blog something like that. Can I take a fragment of your post to my site? Fidelity Baily Clarette
I was excited to uncover this page. I need to to thank you for your time just for this wonderful read!! I definitely appreciated every part of it and I have you saved as a favorite to see new information on your web site. Allene Hartwell Lowry
Crud much unstinting violently pessimistically far camel inanimately a remade dove disagreed hellish one concisely before with this erotic frivolous. Karissa Carey Tat
I think this is among the most significant info for me. And i am glad reading your article. But want to remark on some general things, The web site style is wonderful, the articles is really excellent : D. Good job, cheers Nettle Aldric Peadar
Having read this I believed it was rather informative. I appreciate you spending some time and effort to put this informative article together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worth it! Amandie Ax Ursi
There are certainly a lot of details like that to take into consideration. That is a great point to bring up. I offer the thoughts above as general inspiration but clearly there are questions like the one you bring up where the most important thing will be working in honest good faith. I don?t know if best practices have emerged around things like that, but I am sure that your job is clearly identified as a fair game. Both boys and girls feel the impact of just a moment?s pleasure, for the rest of their lives. Dinah Mickey Oakleil
Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point. You obviously know what youre talking about, why waste your intelligence on just posting videos to your weblog when you could be giving us something enlightening to read? Stormie Yuma Prince
Greetings! Very useful advice in this particular post! It is the little changes that will make the greatest changes. Thanks a lot for sharing! Gretta Thaine Jenness
hi!,I like your writing so much! percentage we keep up a correspondence more approximately your post on AOL? I require an expert in this area to resolve my problem. Maybe that is you! Having a look forward to see you. Philippine Cullie Amaryl
wonderful issues altogether, you just won a logo new reader. What might you suggest about your post that you simply made a few days ago? Any positive?| Jerrilee Burr Landahl
This article gives clear idea for the new people of blogging, that in fact how to do blogging.
I used to be recommended this website by my cousin. I am now not
sure whether or not this put up is written by means of him as no one else recognize
such exact approximately my trouble. You are wonderful! Thanks!
optimal post
I am grateful to you for this beautiful content. I have included the content in my favorites list and will always wait for your new blog posts.
Blog nice articles! Favorite add.