configuration - How to serve images with nginx - Stack Overflow (https://cdn.sstatic.net/Sites/stackoverflow/Img/favicon.ico?v=ec617d715196) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (Stack Overflow) (/opensearch.xml) (https://stackoverflow.com/questions/18954827/how-to-serve-images-with-nginx) (https://cdn.sstatic.net/Shared/stacks.css?v=d6a266655a25) (https://cdn.sstatic.net/Sites/stackoverflow/primary.css?v=22fb2cb11723) (Feed for question 'How to serve images with nginx') (/feeds/question/18954827) (https://cdn.sstatic.net/Shared/Channels/channels.css?v=5981bb1a5bd7) (https://accounts.google.com/gsi/style) (site logo) Join Stack Overflow By clicking “Sign up”, you agree to our (/legal/terms-of-service/public) terms of service and acknowledge you have read our (/legal/privacy-policy) privacy policy . (59e99b481907aca79504282706e4b1db65c79b5bb11a4cbc1d88997106647265) (1) (2.0) Sign up with Google Sign up with GitHub OR (59e99b481907aca79504282706e4b1db65c79b5bb11a4cbc1d88997106647265) (1) () () () () () () Email Password (8+ characters (at least 1 letter & 1 number)) Sign up Already have an account? (/users/login) Log in (59e99b481907aca79504282706e4b1db65c79b5bb11a4cbc1d88997106647265) () Skip to main content (https://stackoverflow.com) Stack Overflow (https://stackoverflow.co/) About Products (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav-bar&utm_content=overflowai) OverflowAI (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams) Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising) Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand (https://stackoverflow.co/teams/ai/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-ai) OverflowAI GenAI features for Teams (https://stackoverflow.co/api-solutions/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api) OverflowAPI Train & fine-tune LLMs (https://stackoverflow.co/labs/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=labs) Labs The future of collective knowledge sharing (https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) About the company (https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog) Visit the blog (Search…) () Loading… (https://stackoverflow.com) current community (https://stackoverflow.com) (Stack Overflow) Stack Overflow (https://stackoverflow.com/help) help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) chat (https://meta.stackoverflow.com) (Meta Stack Overflow) Meta Stack Overflow your communities (https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f18954827%2fhow-to-serve-images-with-nginx) Sign up or (https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f18954827%2fhow-to-serve-images-with-nginx) log in to customize your list. (https://stackexchange.com/sites) more stack exchange communities (https://stackoverflow.blog) company blog (Click to show search) (https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f18954827%2fhow-to-serve-images-with-nginx) Log in (https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f18954827%2fhow-to-serve-images-with-nginx) Sign up Let's set up your homepage Select a few topics you're interested in: python javascript c# reactjs java android html flutter c++ node.js typescript css r php angular next.js spring-boot machine-learning sql excel ios azure docker Or search from our full list: (Search) javascript python java c# php android html jquery c++ css ios sql mysql r reactjs node.js arrays c asp.net json python-3.x .net ruby-on-rails sql-server swift django angular objective-c excel pandas angularjs regex typescript ruby linux ajax iphone vba xml laravel spring asp.net-mvc database wordpress string flutter postgresql mongodb wpf windows amazon-web-services xcode bash git oracle-database spring-boot dataframe azure firebase list multithreading docker vb.net react-native eclipse algorithm powershell macos visual-studio numpy image forms scala function vue.js performance twitter-bootstrap selenium winforms kotlin loops express dart hibernate sqlite matlab python-2.7 shell rest apache entity-framework android-studio csv maven api linq qt dictionary unit-testing asp.net-core facebook tensorflow apache-spark file swing class unity-game-engine sorting date authentication go symfony t-sql opencv matplotlib .htaccess google-chrome for-loop datetime codeigniter http perl validation sockets google-maps object uitableview xaml oop if-statement visual-studio-code cordova ubuntu web-services email android-layout github spring-mvc elasticsearch kubernetes selenium-webdriver ms-access user-interface parsing ggplot2 pointers google-sheets machine-learning c++11 security google-apps-script flask ruby-on-rails-3 templates nginx variables exception sql-server-2008 gradle debugging tkinter listview delphi jpa asynchronous pdf web-scraping haskell jsp ssl amazon-s3 google-cloud-platform jenkins testing xamarin wcf npm batch-file generics ionic-framework network-programming unix recursion google-app-engine mongoose visual-studio-2010 .net-core android-fragments assembly animation math next.js session svg hadoop intellij-idea curl django-models join rust winapi laravel-5 url heroku http-redirect tomcat google-cloud-firestore inheritance webpack keras image-processing gcc asp.net-mvc-4 logging dom web swiftui matrix pyspark actionscript-3 button post optimization firebase-realtime-database jquery-ui iis cocoa xpath d3.js javafx firefox internet-explorer xslt caching select asp.net-mvc-3 opengl events asp.net-web-api plot dplyr magento encryption search stored-procedures amazon-ec2 ruby-on-rails-4 memory audio canvas multidimensional-array jsf random vector cookies redux input facebook-graph-api flash xamarin.forms indexing arraylist ipad cocoa-touch data-structures video apache-kafka model-view-controller serialization jdbc woocommerce azure-devops routes razor awk servlets mod-rewrite beautifulsoup docker-compose excel-formula filter iframe aws-lambda design-patterns text django-rest-framework visual-c++ cakephp mobile android-intent react-hooks struct methods groovy mvvm ssh lambda checkbox ecmascript-6 google-chrome-extension time grails installation sharepoint cmake shiny spring-security jakarta-ee android-recyclerview plsql core-data types meteor android-activity sed bootstrap-4 websocket activerecord graph replace scikit-learn file-upload group-by vim junit boost deep-learning import sass memory-management error-handling async-await eloquent dynamic soap silverlight dependency-injection charts layout apache-spark-sql deployment browser gridview svn while-loop google-bigquery vuejs2 ffmpeg dll highcharts view foreach plugins makefile c#-4.0 redis reporting-services jupyter-notebook merge server unicode https reflection google-maps-api-3 twitter oauth-2.0 extjs pytorch axios terminal pip split mysqli cmd encoding django-views automation database-design collections hash netbeans build data-binding ember.js tcp sqlalchemy pdo apache-flex concurrency entity-framework-core command-line spring-data-jpa printing react-redux java-8 jestjs service html-table lua neo4j ansible material-ui parameters module enums visual-studio-2012 flexbox promise outlook webview firebase-authentication web-applications uwp jquery-mobile utf-8 datatable python-requests parallel-processing drop-down-menu colors scroll hive scipy tfs count syntax ms-word twitter-bootstrap-3 ssis google-analytics fonts three.js powerbi rxjs constructor graphql file-io paypal discord cassandra socket.io graphics compiler-errors gwt react-router nlp solr url-rewriting backbone.js memory-leaks datatables oauth terraform datagridview drupal oracle11g zend-framework neural-network knockout.js triggers django-forms interface angular-material google-api casting jmeter linked-list path proxy timer django-templates arduino orm directory visual-studio-2015 parse-platform windows-phone-7 cron push-notification conditional-statements primefaces functional-programming pagination model jar xamarin.android hyperlink uiview gitlab visual-studio-2013 vbscript google-cloud-functions azure-active-directory jwt download swift3 sql-server-2005 configuration process pygame rspec properties combobox callback windows-phone-8 linux-kernel safari permissions scrapy raspberry-pi scripting emacs clojure x86 scope io compilation mongodb-query nhibernate responsive-design expo angularjs-directive azure-functions request bluetooth dns 3d binding reference discord.js architecture playframework pyqt version-control doctrine-orm package get sql-server-2012 rubygems f# autocomplete openssl datepicker kendo-ui tree jackson pycharm controller yii nested grep xamarin.ios static dockerfile statistics transactions datagrid null active-directory uiviewcontroller webforms phpmyadmin discord.py notifications computer-vision sas duplicates mocking youtube nullpointerexception yaml menu sum bitmap blazor asp.net-mvc-5 electron visual-studio-2008 time-series yii2 jsf-2 css-selectors stl android-listview floating-point cryptography ant stream hashmap character-encoding msbuild sdk asp.net-core-mvc google-drive-api selenium-chromedriver jboss joomla cors navigation devise anaconda background camera multiprocessing pyqt5 binary cuda frontend linq-to-sql iterator mariadb onclick plotly ios7 rabbitmq android-jetpack-compose android-asynctask microsoft-graph-api tabs insert laravel-4 uicollectionview environment-variables amazon-dynamodb linker console xsd coldfusion upload continuous-integration ftp textview opengl-es operating-system vuejs3 mockito localization macros formatting xml-parsing json.net kivy type-conversion data.table timestamp calendar integer segmentation-fault android-ndk drag-and-drop prolog char crash jasmine automated-tests dependencies geometry android-gradle-plugin itext firebase-cloud-messaging header fortran sprite-kit mfc attributes nuxt.js nosql format azure-pipelines nestjs odoo db2 jquery-plugins jenkins-pipeline leaflet event-handling flutter-layout julia postman annotations keyboard textbox arm visual-studio-2017 gulp libgdx stripe-payments xampp synchronization crystal-reports timezone dom-events uikit azure-web-app-service android-emulator swagger wso2 sequelize.js namespaces aggregation-framework uiscrollview jvm google-sheets-formula chart.js com subprocess geolocation centos webdriver snowflake-cloud-data-platform html5-canvas garbage-collection widget dialog numbers concatenation sql-update qml set windows-10 tuples mapreduce smtp java-stream ionic2 rotation modal-dialog spring-data android-edittext http-headers nuget doctrine radio-button sonarqube grid lucene xmlhttprequest internationalization listbox initialization switch-statement components google-play apache-camel boolean serial-port ldap ios5 youtube-api return gdb pivot latex eclipse-plugin frameworks tags containers github-actions dataset asp-classic label foreign-keys subquery c++17 copy uinavigationcontroller delegates google-cloud-storage migration struts2 base64 protractor sql-server-2008-r2 find embedded queue uibutton arguments composer-php append jaxb zip stack cucumber autolayout ide entity-framework-6 popup iteration airflow tailwind-css windows-7 r-markdown ssl-certificate vb6 gmail hover jqgrid g++ udp Next You’ll be prompted to create an account to view your personalized homepage. (/) Home (/questions) Questions (/tags) Tags (/beta/discussions) Discussions Labs (https://chat.stackoverflow.com/?tab=all&sort=active) Chat (/users) Users (/jobs?source=so-left-nav) Jobs (https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav) Companies Collectives Communities for your favorite technologies. (/collectives-all) Explore all Collectives Teams () Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Try Teams for free (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) Explore Teams Teams Ask questions, find answers and collaborate at work with Stack Overflow for Teams. (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact) Explore Teams Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. (/collectives) Learn more about Collectives Teams Q&A for work Connect and share knowledge within a single location that is structured and easy to search. (https://stackoverflow.co/teams/) Learn more about Teams (Illustration of upvote icon after it is clicked) Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. Upvoting indicates when questions and answers are useful. (https://stackoverflow.com/help/whats-reputation) What's reputation and how do I get it? Instead, you can save this post to reference later. Save this post for later Not now (Illustration of upvote icon after it is clicked) Hang on, you can't downvote just yet. You'll need to complete a few actions and gain 125 reputation points before being able to downvote. Casting downvotes indicate issues with quality, effort, or accuracay of a post. (https://stackoverflow.com/help/whats-reputation) What's reputation and how do I get it? Instead, you can try suggesting an edit to improve the post. Suggest edit No thanks (https://cdn.sstatic.net/Sites/stackoverflow/Img/apple-touch-icon.png?v=c78bd457575a) (/questions/18954827/how-to-serve-images-with-nginx) How to serve images with nginx (/questions/ask) Ask Question (2013-09-23 08:31:09Z) Asked 11 years, 6 months ago Modified (?lastactivity) (2023-06-13 03:21:49Z) 1 year, 9 months ago (Viewed 115,934 times) Viewed 116k times This question shows research effort; it is useful and clear (70:3:31e,16:0a2db8a6dbe87b19,10:1743973864,16:116f6bc92242c048,8:18954827,46f00f9593019f8a446ffdedd2e50ed62366c30b0896d35f54bc6f17d4580f63) 24 (This question does not show any research effort; it is unclear or not useful) (70:3:31e,16:1115c351979eaede,10:1743973864,16:00487ed26ed31dd0,8:18954827,997b3647b2c87ad711d5ff5b0be73703aedbc623ceac87497504fca8b8689762) Save this question. (/posts/18954827/timeline) Show activity on this post. I am completely new to nginx and I am asked to find a way to serve Map Tiles that are separated according to the zoom levels. The image file structure is like ~/data/images/7/65/70.png where 7 is the zoom level, 65 and 70 are the lon-lat values. The folder 65 contains many files such as 71.png, 72.png and etc. I have installed Nginx properly and I can get Welcome to nginx message. I have followed the instructions in http://nginx.org/en/docs/beginners_guide.html and created the /data/www and /data/images directories. I have placed index.html file under /data/www and tile images under /data/images . Then I modified the configuration file by adding following lines in http tags: server { location / { root /data/www; } location /images/ { root /data; } } After reloading the config file and entering localhost on the browser I can neither get the index.html file nor see the images. What I am trying to do is to display the image when I enter something as: http://localhost/1.0.0/basemap/7/65/70.png 7: folder indicating 7th zoom level 65: folder indicating the latitude 70.png: file indicating the longitude (folder 65 includes many png files) What am I missing? (/questions/tagged/configuration) (show questions tagged 'configuration') configuration (/questions/tagged/nginx) (show questions tagged 'nginx') nginx (/questions/tagged/configuration-files) (show questions tagged 'configuration-files') configuration-files (/q/18954827) (Short permalink to this question) Share Share a link to this question Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/18954827/edit) () Improve this question Follow (70:3:31e,16:82eae37b4079cb97,10:1743973864,16:ad97ebf2eb251c98,8:18954827,a1b102f469842bbc9f86eb4de00d9f48d69b6f4610f3a2e4e54f9ded9f9ca90b) Follow this question to receive notifications (/posts/18954827/revisions) (show all edits to this post) edited (2013-09-23 09:01:37Z) Sep 23, 2013 at 9:01 iso_9001_ asked (2013-09-23 08:31:09Z) Sep 23, 2013 at 8:31 (/users/1376472/iso-9001) (iso_9001_'s user avatar) (/users/1376472/iso-9001) iso_9001_ iso_9001_ (reputation score) 2,881 (7 gold badges) 7 7 gold badges (34 silver badges) 34 34 silver badges (48 bronze badges) 48 48 bronze badges 4 why create a new server block, what is the URL that you are planning to access these images by, are they still localhost or do you have a domain that points to your server – (/users/2149092/mohammad-abushady) (42,977 reputation) Mohammad AbuShady Commented (2013-09-23 08:44:24Z, License: CC BY-SA 3.0) Sep 23, 2013 at 8:44 (this comment was edited 1 time) (number of 'useful comment' votes received) 1 they are localhost. there is no domain. I created the new server block because the beginner's guide says so – (/users/1376472/iso-9001) (2,881 reputation) iso_9001_ Commented (2013-09-23 08:47:21Z, License: CC BY-SA 3.0) Sep 23, 2013 at 8:47 do you have a sites-enabled and sites-available folder inside /etc/nginx ? – (/users/2149092/mohammad-abushady) (42,977 reputation) Mohammad AbuShady Commented (2013-09-23 08:52:09Z, License: CC BY-SA 3.0) Sep 23, 2013 at 8:52 (number of 'useful comment' votes received) 1 Yes, those folders are inside /etc/nginx and both have default file inside. I also edited the OP, please check – (/users/1376472/iso-9001) (2,881 reputation) iso_9001_ Commented (2013-09-23 09:00:41Z, License: CC BY-SA 3.0) Sep 23, 2013 at 9:00 (Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.) Add a comment | (Expand to show all comments on this post) 3 Answers 3 Sorted by: (/questions/18954827/how-to-serve-images-with-nginx?answertab=scoredesc#tab-top) Reset to default (scoredesc) Highest score (default) (trending) Trending (recent votes count more) (modifieddesc) Date modified (newest first) (createdasc) Date created (oldest first) This answer is useful (70:3:31e,16:524c6bdfbe9e0023,10:1743973864,16:8a17365fcce68633,8:18955629,750e0d4fc361c1ed22405e394b59cf48c39b45d864a71e35271978a4c1dbec5b) 35 (This answer is not useful) (70:3:31e,16:0a2ebbc3093a199c,10:1743973864,16:85b70188c6524649,8:18955629,4276df7373e50fa03e6ebc9074c67834ca68854e7179c37bb1a9350d226b2fbc) Save this answer. (Loading when this answer was accepted…) (/posts/18955629/timeline) Show activity on this post. Ok, let me explain something, you already have a localhost server, which is defined inside a file called default that is the file that causes the "Welcome to nginx" or something to appear, and I believe you can't create a new server with the same server_name , let's remove that and make your localhost serve only those images, First we need to delete the default file from sites-enabled , it will still exist inside sites-available if you ever want to get it back. ( note that all files inside sites-enabled are simply symlinks from the files inside sites-available ) We create a new file inside sites-available and call it whatever you want, images-app for example create the new server inside the images-app file, I'll assume that the root of the app is inside a folder called /data of course you will map that to your own server structure. server { server_name localhost; root /data; index index.html; location / { try_files $uri =404; } } now we go to sites-enabled and enable this site we created inside sites-available sudo ln -s /etc/nginx/sites-available/images-app /etc/nginx/sites-enabled/ make sure that all the nginx config are correct sudo nginx -t If nothing is wrong we can go ahead and reload nginx settings sudo service nginx reload (/a/18955629) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/3.0/) (The current license for this post: CC BY-SA 3.0) CC BY-SA 3.0 (/posts/18955629/edit) () Improve this answer Follow (70:3:31e,16:d00b61fe4748e0ff,10:1743973864,16:bd38056a11ed8d56,8:18955629,19db988d185f4f3a0ca5d86feb0d9e3f46dfdf9338960bc3af366f1c6d1702da) Follow this answer to receive notifications (/posts/18955629/revisions) (show all edits to this post) edited (2013-09-23 09:24:39Z) Sep 23, 2013 at 9:24 answered (2013-09-23 09:15:42Z) Sep 23, 2013 at 9:15 (/users/2149092/mohammad-abushady) (Mohammad AbuShady's user avatar) (/users/2149092/mohammad-abushady) Mohammad AbuShady Mohammad AbuShady (reputation score 42,977) 43k (11 gold badges) 11 11 gold badges (81 silver badges) 81 81 silver badges (89 bronze badges) 89 89 bronze badges 3 (number of 'useful comment' votes received) 1 This is very detailed and instructive. I had to delete my virtual machine due to disk error. I am now re-installing it and will try it when installation is done. Thank you very much – (/users/1376472/iso-9001) (2,881 reputation) iso_9001_ Commented (2013-09-23 09:22:13Z, License: CC BY-SA 3.0) Sep 23, 2013 at 9:22 (number of 'useful comment' votes received) 2 I have just had the chance to try this out and it worked like a charm. Thank you for the detailed answer and your time – (/users/1376472/iso-9001) (2,881 reputation) iso_9001_ Commented (2013-09-23 12:50:43Z, License: CC BY-SA 3.0) Sep 23, 2013 at 12:50 or just modify this default file already having half of the instruction to set up your own server. – (/users/773595/vdegenne) (13,356 reputation) vdegenne Commented (2022-12-05 15:14:33Z, License: CC BY-SA 4.0) Dec 5, 2022 at 15:14 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:7b412cb6e4518e12,10:1743973864,16:15e6458e20414eee,8:53799210,74c9748a30b2e914040584f56d1f14bd2eb21c311154a080fa9b8747a8da3431) 11 (This answer is not useful) (70:3:31e,16:b203b9a733fec10f,10:1743973864,16:6378ee0cfb03653b,8:53799210,fb598fdf83501b0e232981ac2df987315797eb78de4ae9cec58ad7aef06c9ef5) Save this answer. (Loading when this answer was accepted…) (/posts/53799210/timeline) Show activity on this post. For my case I just edited /etc/nginx/sites-enabled/default file. I added following config: location /images/ { root /data; } and placed images under /data/images : (https://i.sstatic.net/u3OTU.png) (enter image description here) and url works: (http://localhost/images/example.png) http://localhost/images/example.png I use VS Code as SuperUser. (I know it is bad, but I accept risks) It helps a lot with root access file editing: (https://i.sstatic.net/dN0f3.png) (enter image description here) (/a/53799210) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/53799210/edit) () Improve this answer Follow (70:3:31e,16:932d01a0a73e57ea,10:1743973864,16:a50431be6ffa0d44,8:53799210,2d8dc546daec4165907f98f2d2a1032d940c9a5264bd6a4ddd02da283ed11eaa) Follow this answer to receive notifications answered (2018-12-16 03:33:39Z) Dec 16, 2018 at 3:33 (/users/929902/teoman-shipahi) (Teoman shipahi's user avatar) (/users/929902/teoman-shipahi) Teoman shipahi Teoman shipahi (reputation score 23,152) 23.2k (16 gold badges) 16 16 gold badges (144 silver badges) 144 144 silver badges (173 bronze badges) 173 173 bronze badges 1 can i create image hosting service with ngnix? and custom domain ? – (/users/12793212/rohan-devaki) (3,279 reputation) Rohan Devaki Commented (2022-02-18 15:21:44Z, License: CC BY-SA 4.0) Feb 18, 2022 at 15:21 (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) This answer is useful (70:3:31e,16:4a52e83baf751a6a,10:1743973864,16:960092ce91fd9a0f,8:36476720,0b8bd5e28e0b867c14cad58ed3df2777eefbe2a6491d74d5e45d503af343f68a) 6 (This answer is not useful) (70:3:31e,16:ae4f8dd1c4539793,10:1743973864,16:0df448b003567a57,8:36476720,6c6c7bebfdbe800e42be18cec3025c2f94dc2ec05c3f8d8250374113e196f9e3) Save this answer. (Loading when this answer was accepted…) (/posts/36476720/timeline) Show activity on this post. I'm also new to nginx, Here is my solution that is similar with Mohammad AbuShady's answer : delete sites-enabled/default create the whatever.conf in /etc/nginx/conf.d/ The reason is: sites-enabled/default has defined a server that is listening on 80 rooting with /var/www/html server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } } the nginx.conf file includes other conf files include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; pay attention on permission the 1st edition of my.conf is root on /home/myusername/, but will get 403 Forbidden error, check the error.log: 2016/04/07 20:12:44 [error] 12466#0: *2 open() "/home/myusername/data/a" failed (13: Permission denied), client: 127.0.0.1, server: , request: "GET /a HTTP/1.1", host: "localhost" (/a/36476720) (Short permalink to this answer) Share Share a link to this answer Copy link (https://creativecommons.org/licenses/by-sa/4.0/) (The current license for this post: CC BY-SA 4.0) CC BY-SA 4.0 (/posts/36476720/edit) () Improve this answer Follow (70:3:31e,16:48b7c13a76a8ea03,10:1743973864,16:d48db4117e02a6b4,8:36476720,7312b4c8b7b6d322a45e68dc024657a6d73899843973df4af3a810a91d184093) Follow this answer to receive notifications (/posts/36476720/revisions) (show all edits to this post) edited (2023-06-13 03:21:49Z) Jun 13, 2023 at 3:21 answered (2016-04-07 12:49:37Z) Apr 7, 2016 at 12:49 (/users/3809076/scozv) (scozv's user avatar) (/users/3809076/scozv) scozv scozv (reputation score) 211 (2 silver badges) 2 2 silver badges (4 bronze badges) 4 4 bronze badges (Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.) Add a comment | (Expand to show all comments on this post) (18954827) (false) () (0) Your Answer (True) Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question . Provide details and share your research! But avoid … Asking for help, clarification, or responding to other answers. Making statements based on opinion; back them up with references or personal experience. To learn more, see our (/help/how-to-answer) tips on writing great answers . Draft saved Draft discarded (59e99b481907aca79504282706e4b1db65c79b5bb11a4cbc1d88997106647265) Sign up or (/users/login?ssrc=question_page&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f18954827%2fhow-to-serve-images-with-nginx%23new-answer) log in Sign up using Google Sign up using Email and Password (false) (false) Submit Post as a guest Name () () Email Required, but never shown () () Post as a guest Name () () Email Required, but never shown () () Post Your Answer Discard By clicking “Post Your Answer”, you agree to our (https://stackoverflow.com/legal/terms-of-service/public) terms of service and acknowledge you have read our (https://stackoverflow.com/legal/privacy-policy) privacy policy .(1) Start asking to get answers Find the answer to your question by asking. (/questions/ask) Ask question Explore related questions (/questions/tagged/configuration) (show questions tagged 'configuration') configuration (/questions/tagged/nginx) (show questions tagged 'nginx') nginx (/questions/tagged/configuration-files) (show questions tagged 'configuration-files') configuration-files See similar questions with these tags. The Overflow Blog (https://stackoverflow.blog/2025/04/03/from-training-to-inference-the-new-role-of-web-data-in-llms/?cb=1) From training to inference: The new role of web data in LLMs (https://stackoverflow.blog/2025/04/04/is-ai-a-bubble-or-a-revolution-the-answer-is-yes/?cb=1) Is AI a bubble or a revolution? The answer is yes. Featured on Meta (Meta Stack Exchange) (https://meta.stackexchange.com/questions/407927/changes-to-reporting-for-the-status-review-escalation-process?cb=1) Changes to reporting for the [status-review] escalation process (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned?cb=1) Policy: Generative AI (e.g., ChatGPT) is banned (Meta Stack Overflow) (https://meta.stackoverflow.com/questions/433466/a-discussion-about-closed-and-potentially-useful-posts-on-stack-overflow?cb=1) A discussion about closed (and potentially useful) posts on Stack Overflow (https://chat.stackoverflow.com/) (9 users active in 13 rooms the last 60 minutes) 9 people chatting Linked (https://stackoverflow.com/q/78979968?lq=1) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/78979968/angular-app-migrated-from-8-to-16-now-after-the-deployment-nginx-server-retur?noredirect=1&lq=1) Angular app migrated from 8 to 16. Now, after the deployment, nginx server returns 403 forbidden error for the images inside assets folder (https://stackoverflow.com/q/66977178?lq=1) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/66977178/vue-production-images-folder-is-not-updating?noredirect=1&lq=1) Vue production images folder is not updating? Related (https://stackoverflow.com/q/1604413?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/1604413/configure-nginx-to-serve-cached-images?rq=3) Configure nginx to serve cached images (https://stackoverflow.com/q/10309357?rq=3) (Question score (upvotes - downvotes)) 13 (https://stackoverflow.com/questions/10309357/nginx-serve-only-images?rq=3) nginx - serve only images (https://stackoverflow.com/q/19101882?rq=3) (Question score (upvotes - downvotes)) 14 (https://stackoverflow.com/questions/19101882/nginx-serve-jpg-images-from-different-root-and-location?rq=3) Nginx : Serve JPG images from different root and location (https://stackoverflow.com/q/27075221?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/27075221/serve-images-using-web-server?rq=3) Serve images using web server (https://stackoverflow.com/q/40976266?rq=3) (Question score (upvotes - downvotes)) 0 (https://stackoverflow.com/questions/40976266/nginx-serving-static-files?rq=3) NGINX serving static files (https://stackoverflow.com/q/42720164?rq=3) (Question score (upvotes - downvotes)) 3 (https://stackoverflow.com/questions/42720164/how-to-set-up-nginx-to-serve-image-files-without-extension?rq=3) How to set up Nginx to serve image files without extension (https://stackoverflow.com/q/50892918?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/50892918/nginx-giving-404-on-valid-image-file?rq=3) Nginx giving 404 on valid image file (https://stackoverflow.com/q/53561718?rq=3) (Question score (upvotes - downvotes)) 3 (https://stackoverflow.com/questions/53561718/unable-to-serve-static-content-images-on-the-server-nginx-ubuntu?rq=3) Unable to serve static content "images" on the server - nginx ubuntu (https://stackoverflow.com/q/60166226?rq=3) (Question score (upvotes - downvotes)) 2 (https://stackoverflow.com/questions/60166226/configuring-nginx-to-server-assets-files-in-angular?rq=3) Configuring nginx to server assets files in angular (https://stackoverflow.com/q/69171002?rq=3) (Question score (upvotes - downvotes)) 1 (https://stackoverflow.com/questions/69171002/nginx-serving-angular-static-files?rq=3) Nginx serving angular static files (https://stackexchange.com/questions?tab=hot) Hot Network Questions (Worldbuilding Stack Exchange) (https://worldbuilding.stackexchange.com/questions/265751/is-it-possible-the-homo-genus-could-evolve-if-magically-all-of-earths-fossil) Is it possible the homo genus could evolve if, magically, all of earth's fossil fuels had been burned within a 1000 year span? (Quantum Computing Stack Exchange) (https://quantumcomputing.stackexchange.com/questions/41605/single-shot-error-correction-in-high-dimensional-topological-codes-and-knill-or) Single-shot error correction in high dimensional topological codes and Knill or Steane gadget (TeX - LaTeX Stack Exchange) (https://tex.stackexchange.com/questions/740359/what-is-causing-this-extra-line-spacing) What is causing this extra line spacing? (Electrical Engineering Stack Exchange) (https://electronics.stackexchange.com/questions/743200/does-neutral-wire-carry-power) Does neutral wire carry power? (Mathematics Stack Exchange) (https://math.stackexchange.com/questions/5053047/where-is-my-proof-of-the-quotient-rule-wrong) Where is my proof of the quotient rule wrong? (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31545/what-is-the-origin-of-corruption-in-rom-memories) What is the origin of corruption in ROM memories? (Physics Stack Exchange) (https://physics.stackexchange.com/questions/847007/intuition-for-maupertuis-action-and-the-principle-of-least-action) Intuition for Maupertuis' action and the principle of least action (Retrocomputing Stack Exchange) (https://retrocomputing.stackexchange.com/questions/31550/is-there-a-way-to-save-the-current-path-to-a-variable-in-a-batch-file-in-ms-dos) Is there a way to save the current path to a variable in a batch file in MS-DOS 6.0 without third-party tools? (Photography Stack Exchange) (https://photo.stackexchange.com/questions/136452/does-squinching-work-with-epicanthal-folds) Does squinching work with epicanthal folds? (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/316658/how-to-fix-lawn-where-car-drives-over) How to fix lawn where car drives over (Home Improvement Stack Exchange) (https://diy.stackexchange.com/questions/316584/are-these-concrete-steps-fixable) Are these concrete steps fixable? (MathOverflow) (https://mathoverflow.net/questions/490606/reconstruct-the-metric-from-partial-information-of-the-geodesic-distance) Reconstruct the metric from partial information of the geodesic distance (Bicycles Stack Exchange) (https://bicycles.stackexchange.com/questions/96490/what-causes-this-level-of-dry-rot) What causes THIS level of dry rot? (The Workplace Stack Exchange) (https://workplace.stackexchange.com/questions/200666/how-can-i-assert-myself-and-earn-respect-in-a-new-team-where-the-tech-lead-and-a) How can I assert myself and earn respect in a new team where the tech lead and architect dominate discussions and dismiss my input? (Cross Validated) (https://stats.stackexchange.com/questions/663568/does-bayesian-estimation-need-finite-population-correction) Does bayesian estimation need finite population correction? (Role-playing Games Stack Exchange) (https://rpg.stackexchange.com/questions/215177/can-i-carry-a-grappled-foe-with-a-jump-jump) Can I carry a Grappled foe with a Jump jump? (Movies & TV Stack Exchange) (https://movies.stackexchange.com/questions/125014/why-is-the-movie-titled-the-brutalist) Why is the movie titled "The Brutalist"? (French Language Stack Exchange) (https://french.stackexchange.com/questions/55713/pronunciation-of-par-hasard) Pronunciation of "par hasard" (Economics Stack Exchange) (https://economics.stackexchange.com/questions/60191/does-it-make-sense-to-treat-trade-deficit-as-tariffs) Does it make sense to treat trade deficit as tariffs? (Academia Stack Exchange) (https://academia.stackexchange.com/questions/217775/what-should-i-do-if-i-lack-fundamental-knowledge-and-only-got-into-a-phd-program) What should I do if I lack fundamental knowledge and only got into a PhD program due to luck? (Stack Overflow) (https://stackoverflow.com/questions/79555310/implicit-declaration-of-standard-function-in-c) Implicit declaration of standard function in C (Politics Stack Exchange) (https://politics.stackexchange.com/questions/91277/what-are-the-advantages-for-the-us-in-starting-a-trade-war-with-everyone-else-at) What are the advantages for the US in starting a trade war with everyone else at the same time? (Mathematica Stack Exchange) (https://mathematica.stackexchange.com/questions/312023/unwanted-vector-in-vectorplot) Unwanted vector in VectorPlot (Code Golf Stack Exchange) (https://codegolf.stackexchange.com/questions/279050/efficiently-navigate-a-6-sided-die) Efficiently navigate a 6 sided die (/feeds/question/18954827) (Feed of this question and its answers) Question feed Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. (https://stackoverflow.com/feeds/question/18954827) () (https://stackoverflow.com) (https://stackoverflow.com) Stack Overflow (/questions) Questions (/help) Help (https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com) Chat (https://stackoverflow.co/) Products (https://stackoverflow.co/teams/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams) Teams (https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising) Advertising (https://stackoverflow.co/advertising/employer-branding/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=talent) Talent (https://stackoverflow.co/) Company (https://stackoverflow.co/) About (https://stackoverflow.co/company/press/) Press (https://stackoverflow.co/company/work-here/) Work Here (https://stackoverflow.com/legal) Legal (https://stackoverflow.com/legal/privacy-policy) Privacy Policy (https://stackoverflow.com/legal/terms-of-service/public) Terms of Service (/contact) Contact Us Your Privacy Choices (https://stackoverflow.com/legal/cookie-policy) Cookie Policy (https://stackexchange.com) Stack Exchange Network (https://stackexchange.com/sites#technology) Technology (https://stackexchange.com/sites#culturerecreation) Culture & recreation (https://stackexchange.com/sites#lifearts) Life & arts (https://stackexchange.com/sites#science) Science (https://stackexchange.com/sites#professional) Professional (https://stackexchange.com/sites#business) Business (https://api.stackexchange.com/) API (https://data.stackexchange.com/) Data (https://stackoverflow.blog?blb=1) Blog (https://www.facebook.com/officialstackoverflow/) Facebook (https://twitter.com/stackoverflow) Twitter (https://linkedin.com/company/stack-overflow) LinkedIn (https://www.instagram.com/thestackoverflow) Instagram Site design / logo © 2025 Stack Exchange Inc; user contributions licensed under (https://stackoverflow.com/help/licensing) CC BY-SA . rev 2025.4.4.24803