Oh good, another nginx topic.



  • Despite a lot of searching, I've not found my issue listed anywhere, so here goes.

    Setting this up, DNS of a spare URL I own is pointed at digital ocean vps, added the server settings (attached below) into sites-available, this is then symlinked into sites-enabled. Have changed config.json of nodebb to not use port 4567, restarted nginx nodebb and the server.

    Can still only access the site if I use the port.

    Contents of default

    server {
    listen 0.0.0.0:80;
    
    server_name site.info;
    
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
    
        proxy_pass http://127.0.0.1:4567/;
        proxy_redirect off;
    
        # Socket.IO Support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    }
    

    And the contents of config.json

    {
    "base_url": "http://site.info",
    "port": "4567",
    "use_port": false,
    "secret": "shhh",
    "bind_address": "0.0.0.0",
    "database": "redis",
    "redis": {
    "host": "127.0.0.1",
    "port": "6379",
    "password": "also shhhh",
    "database": "0"
    },
    "bcrypt_rounds": 12,
    "upload_path": "/public/uploads",
    "relative_path": ""
    }

    Can I also clarify that when I created the symlink inside sites-enabled, it's made the file structure sites-enabled/sites-available/ but sites-available is a fancy blue in colour.

    Running nginx -t gives me this:

    nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:26
    nginx: configuration file /etc/nginx/nginx.conf
    

    Halp... 😞

    Oh and nginx -v == 1.6.0



  • First of all, considering you're using the sites-available / sites-enabled structure, the config (or a symlink to it) needs to actually be in sites-enabled for it to be parsed.
    Second, considering you appear to be running NodeBB on port 6379, you might want to try changing the port you used in proxy_pass accordingly 😉



  • @Xiph 6379 is the default Redis port. The symlink is the sites-available folder which is inside sites-enabled. Wasn't sure if the symlink should just be the default file or the folder to it.



  • @a_5mith said:

    @Xiph 6379 is the default Redis port. The symlink is the sites-available folder which is inside sites-enabled. Wasn't sure if the symlink should just be the default file or the folder to it.

    Oops, my bad. Looks like I misread that, sorry.
    As for the symlink, I don't know your setup but generally the sites-available folder is in the same folder as the sites-enabled folder and they aren't inside of eachother.
    Could you post your nginx.conf, or did you use a script like Centminmod (in which case I can just look up the defaults)?



  • No scripts used. I added the server info above into default of sites-available. Then went into sites-enabled and ran ln -s ../sites-available as per @julian's post in one of the other threads, rebooted server/nginx/nodebb.

    Interestingly, within nginx.conf is the following line

    include /etc/nginx/mime.types;

    Which doesn't exist.

    I've made no changes to nginx.conf or conf.d from the default when you install it.

    I may attempt creating two new files instead of using default as people seem to be having more luck with that than I am with this. 😆



  • @a_5mith Does your nginx.conf contain a line that looks like include /etc/nginx/sites-enabled/*; ? If not, the config might not be parsed, because the only files parsed are nginx.conf and any configuration files specified in include statements.

    EDIT: I'm not sure about your missing mime.types. You can just extract the default one from the zip, though. (it's in nginx-x.x.x/conf/)



  • @Xiph
    ##
    # Virtual Host Configs
    ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
    

    It does indeed. I will look into including the mine.types that way. If anyone else has any other suggestions while I'm doing that, I'm all ears.



  • @a_5mith So, I'm not entirely sure about this, but as far as I remember wildcards only include the files in the specified directory and not in it's subdirectories.
    However, the way you've currently got it setup is that inside of the sites-enabled folder there's a symlink to the sites-available folder, which contains the actual config. What happens if you go to the sites-enabled folder and do ln -s /etc/nginx/sites-available/WhatEverYouNamedYourConfig.conf? (AKA: the direct path to your config file)



  • @Xiph The symlink has now changed to default, rather than sites-available, which seems like what I was after, however no change to the actual issue, still can't access without using the port, even though it's off. 😕



  • @a_5mith said:

    @Xiph The symlink has now changed to default, rather than sites-available, which seems like what I was after, however no change to the actual issue, still can't access without using the port, even though it's off. 😕

    Does it give you a 502 Bad Gateway (or other 5xx) error when trying to access the site on the default port, or does it just not load at all?
    BTW: listen 80; will do, no need to include the 0.0.0.0 🙂 Sorry for the OCD.
    EDIT: Also, just assuming here you posted the server_name as site.info here for privacy reasons. 'cause if that's actually what you're using, that might explain something 😛



  • @Xiph

    Firefox can't establish a connection to the server at site.info.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer's network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Waterfox is permitted to access the Web.
    

    Don't even get the default nginx page. Just won't connect.

    Have changed the listen 80, saw that someone managed to get it working by adding it, as you can tell, it made no difference to me. 😆



  • @a_5mith said:

    @Xiph

    Firefox can't establish a connection to the server at site.info.

    The site could be temporarily unavailable or too busy. Try again in a few moments.
    If you are unable to load any pages, check your computer's network connection.
    If your computer or network is protected by a firewall or proxy, make sure that Waterfox is permitted to access the Web.
    

    Don't even get the default nginx page. Just won't connect.

    Have changed the listen 80, saw that someone managed to get it working by adding it, as you can tell, it made no difference to me. 😆

    Alright, so right now, the main problem appear to be that visitors don't connect to Nginx, at all. If it was just the connection to NodeBB that failed, you would've just gotten a gateway error. The connection between Nginx and NodeBB might be perfectly fine (or not, we don't know yet), but it looks like first we've got to fix Nginx itself.



  • @Xiph I'm inclined to agree. Question: Should I have a conf folder as well as a conf.d, because I don't...



  • @a_5mith said:

    @Xiph I'm inclined to agree. Question: Should I have a conf folder as well as a conf.d, because I don't...

    Well, the location for the missing mime.types your configuration specified was not inside a conf folder, so maybe not, but you can't be sure what other stuff might be missing.

    Some stuff to maybe check:

    • server_name is the same as the domain you're connecting to (duh)
    • You're only listening on IPv4 right now, so if your machine supports IPv6 and you've got an AAAA record set, or you're running on localhost which might be defined as the IPv6 loopback ::1 instead of the IPv4 loopback 127.0.0.1, TL;DR: if you're accessing the site over IPv6, it probably won't work, because Nginx is currently only listening on IPv4.
    • Nginx generally only uses the last version of the configuration that had no errors. If you've changed stuff and Nginx is still complaining when restarting, try fixing it and seeing if it uses the new configuration.


  • Tried both domain & IP, no dice.

    Copied mime.types from that conf folder into nginx and now get

    nginx: [emerg] "worker_processes" directive is not allowed here in /etc/nginx/mime.types:2

    line 2 had worker_processes 1

    This is so much fun. :sarcasm:


  • GNU/Linux Admin

    @a_5mith Your nginx seems to be down because you have a syntax error in your configs:

    nginx: [emerg] open() "/etc/nginx/mime.types" failed (2: No such file or directory) in /etc/nginx/nginx.conf:26
    nginx: configuration file /etc/nginx/nginx.conf

    Was the directory overwritten?

    And earlier I may have made a typo. sites-available and sites-enabled should have the same file structure, and they both should be contained in the same directory. One is not nested inside the other:

    sites-available
      \- default    # These two files are real files
      \- mynodebb
    
    sites-enabled
      \- default    # These two files are symlinks
      \- mynodebb
    

    When I said cd ../sites-enabled && ln -s ../sites-available, I meant to say: cd ../sites-enabled && ln -s ../sites-available/mynodebb, which would create a symlink to the mynodebb file in sites-available, in sites-enabled.

    English 😞



  • @julian Not as far as I'm aware, when I first installed nginx it was an old version, so I had to update. I shall remove nginx and try again with using new files instead of default.



  • Right, I gave up with nginx, so to save my sanity, I went with apache instead. Getting an internal server error when I add the contents of the guide.

    Noticed my bind address is 0.0.0.0, so I changed 127.0.0.1 to 0.0.0.0, but it didn't make a difference. 😞

    EDIT: Sorted it, now running without port. Followed Digital Oceans own guide on setting this up and it worked first time.


Log in to reply
 

Suggested Topics

| |