Question

How can I configure nginx to deliver static HTML pages?

  • Posted on July 4, 2014
  • ren811Asked by ren811

First of all, this is the first time I’m involved with servers, and I just want my droplet to deliver a html file (with images/css, of course).

Thing is, I’m trying to configure Nginx in Ubuntu to show the .html page, and I’m having some issues… When I type my droplet’s IP into the browser bar, I get Nginx’s welcome page. When I try to access <ip>/images/white.png, it throws a 404 error.

Keep in mind that I have nginx installed at /etc/nginx. And I’ve created the folder “data”, which contains “www” and “images” folders.

Here’s what my nginx.conf looks like:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
	worker_connections 768;
	# multi_accept on;
}

http {
	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;
	gzip_disable "msie6";

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# nginx-naxsi config
	##
	# Uncomment it if you installed nginx-naxsi
	##

	#include /etc/nginx/naxsi_core.rules;

	##
	# nginx-passenger config
	##
	# Uncomment it if you installed nginx-passenger
	##
	
	#passenger_root /usr;
	#passenger_ruby /usr/bin/ruby;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
	
	# linha do tutorial
	server {
		listen 80;
		
		location / {
			root data/www;
		}
		
		location /images/ {
			root data;
		}
	}
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

I’m using cyberduck but I can’t escalate permissions to transfer my html

Oooooooh! It’s alive! Thank you very much malikron3!

Now to learn how to put custom fonts in the CSS, and how to create more pages!

Please upload your site using filezilla sftp to this directory nd delete available files

/usr/share/nginx/html

If need help let me know