Question

how to setup subdomain on nginx ubuntu for file hosting

Hi guys, i have installed ubuntu 14.0.4 and nginx, as i found article about How To Set Up nginx Virtual Hosts (Server Blocks) on Ubuntu 12.04 LTS i did, but the result was failed, because i create index.html, but the result just show me:

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com.

Thank you for using nginx.

i need help to setup sub domain and create ftp user that able to upload.

i need this server for file hosting of my website that provide direct links for download. any suggestion?


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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

If your configuration looks like the one you posted:

server {
    listen 80; ## listen for ipv4; this line is default and implied
    #listen [::]:80 default ipv6only=on; ## listen for ipv6

    root /var/www/dl.domain.com/public_html;
    index index.html index.htm;

    # Make site accessible from http://localhost/
    188.27.10.28 dl.domain.com;
}

Then it’s not valid.

You can test your configuration with nginx -t. After I tested your server block, I get the following error:

$ nginx -t
2015/04/22 00:26:32 [emerg] 145#0: unknown directive "188.27.10.28" in /etc/nginx/nginx.conf:39
nginx: [emerg] unknown directive "188.27.10.28" in /etc/nginx/nginx.conf:39
nginx: configuration file /etc/nginx/nginx.conf test failed

This means that the line 188.27.10.28 dl.domain.com; is not valid. You can remove it or comment it out.

After this reload nginx with nginx reload and try it again.

I keep my fingers crossed that it works for you!

Try changing your listen and server_name directives to:

listen       80  default_server;
server_name  _;

This tells nginx to make your server block the default and respond if no other block matches the Host header. Earlier it would respond only to Host: example.com as defined in the tutorial.

Resource link.