Showing .java files in the Browser
July 29, 2014
I have a webserver that serves generated source code - some Java, some Python and some ActionScript. There are also XML schema. This is being served via nginx and each file is downloaded when clicked on.
I wanted to change this so that the file was shown in the browser by default, and can be right clicked to download it.
This can be done by changing the mime types defined on the webserver.
Edit /etc/nginx/mime-types
and modify the text/plain
line to add the extensions of the files you want to show in the browser:
text/plain txt java py xsd as;
Then restart nginx with /etc/init.d/nginx restart
and the files with these extensions will be shown in the browser rather than downloaded.