Nginx problems

Solved Technical Support
  • @tqwhite I reinstalled Homebrew, Nginx, and NodeBB. I removed all my ports. Here is my understanding:

    I set proxy_pass to 0.0.0.0:4567, which is the server NodeBB is using. My server_name is my domain and listen is set to 80. Except, rather then 0.0.0.0:4567, nginx ignores the port number 4567 and uses what I set listen to, which was 80. Since I opened port 80, I received no errors. When I went to port 80, all I saw was the welcome to nginx page, not the actual forum. So I think nginx is not redirecting to NodeBB, but using it's own server. I know this because, after I saved the file and ran sudo nginx again, I get the error that the address 0.0.0.0:80 is already in use.

    @frissdiegurke I copied word for word the NodeBB docs, which is what I have meant. The problem is , the nginx.conf file I installed with home-brew is not similar to the one in the NodeBB docs, so I am not sure.

    Here is it

    server {
            listen       80;
            server_name  eucountries.com;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   html;
                index  index.html index.htm;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://0.0.0.0:4567;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ \.php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #    deny  all;
            #}
  • @Aureney I don't know how to tell you to change your nginx configuration file but you MUST change it if you want NodeBB to work. Since you aren't clearly giving us information we can only piece this together.

    REPLACE your nginx configuration file with this:

    server {
        listen       80;
        server_name  eucountries.com;
    
        root   /var/www/html;
        index  index.php index.html index.htm;
    
        access_log  /var/log/nginx/access.log  main;
        error_log /var/log/nginx/error.log;
    
        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";
        }
    }
    

    You may have to use a different path for the root, access_log or error_log. Those may be dependent upon the operating system you are running.

    Then after you have replaced or changed your nginx configuration file to be what I provided RESTART Nginx. If you do not know how to do that then REBOOT the entire server/computer.

    Report back after you have done that what happens then when you visit http://eucountries.com

  • @rod I replaced the entire contents of nginx.conf with that and restarted nginx. Here is what I get.

    nginx: [emerg] "server" directive is not allowed here in /usr/local/etc/nginx/nginx.conf:1

    My domain, or localhost:80 does not load.

  • @Aureney said in How to replace localhost:4567 with domain name:

    @rod I replaced the entire contents of nginx.conf with that and restarted nginx. Here is what I get.

    nginx: [emerg] "server" directive is not allowed here in /usr/local/etc/nginx/nginx.conf:1

    My domain, or localhost:80 does not load.

    You still have to keep it wrapped by the http block.

    So in best practice your nginx.conf might look like this:

    user http http; # or whatever the user and group is called on your system
    worker_processes  1;
    
    # [...] custom global configuration
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        include conf.d/*.conf;
        include sites-enabled/*;
    }
    

    Then you create a directory called sites-enabled within the same parent directory of your nginx.conf (/usr/local/etc/nginx/ in your case).
    To keep it simple (although not best practice), create your server files within sites-enabled/my-server.conf. Those files contain the server { ... } blocks (one each file) like within @rod's post.

  • @frissdiegurke I copied that into nginx.conf, I get this error when I restart nginx.

    nginx: [emerg] getpwnam("http") failed in /usr/local/etc/nginx/nginx.conf:1

  • @tqwhite said in Nginx problems:

    @charles I think she's running on OS X. That's why she used Homebrew before.

    And you're right. It's very simple and straightforward. That's why I think it very unlikely that her installation of nginx is the problem.

    Yikes! Thanks for letting me know. I would try to help but I switched out of OSX because some things are just easier with Ubuntu

  • I have a similar problem with nginx configuration (and, redirection) - https://community.nodebb.org/topic/8955/where-is-the-htaccess-file/1

    Any help will be apreciated

    SD

  • I sorted out the nginx problems and now its working fine. Just have two questions.

    1. example.com works fine except www.example.com does not. How do you fix this.
    2. how long can NodeBB run? What if the computer is shutdown, does the website still run? What about if it the computer is dismantled?
  • ......bump

  • @Aureney

    1. example.com works fine except www.example.com does not. How do you fix this.

    In your DNS. Forward www.example.com to example.com

    1. how long can NodeBB run?

    Until it runs out of memory.

    What if the computer is shutdown, does the website still run?

    No.


Suggested Topics


  • Login problem 2.0.1

    Solved Technical Support
    2 Votes
    24 Posts
    2k Views

    @murcs You can simply take the file from there and overwrite in your own install.

    For example, if you locate the plugin itself in your folder structure, then open library.js and change

    const utils = require.main.require('./public/src/utils');

    To

    const utils = require.main.require('./src/utils');

    And rebuild, this should then work.

  • Nginx Configuration

    Technical Support
    0 Votes
    5 Posts
    381 Views

    @PitaJ
    Ahh I see, thank you

  • 0 Votes
    13 Posts
    6k Views

    Final update, it worked on the production server!! so now our forum is working properly sending emails the Linux way on a Windows Server OS, quite nice I would say, just as a side note our forum is actually really small in number of users, as it is an internal forum, so I can't assure this setup will work out to other forum's expectations or needs, also I would like to add that this shouldn't be the way to do it on Windows as it is kind of a weird way to handle it so in later versions it would be nice to see it reworked or polished for Windows environments (especially because it looks like the program used to simulate sendmail on Windows is no longer receiving maintenance).

  • SSL, nginx, location

    Technical Support
    0 Votes
    5 Posts
    2k Views

    config.json:

    { "url": "http://sub.domen.com/forum", "secret": "ecb356d8-120a-433c-866f-46589291e491", "database": "redis", "redis": { "host": "127.0.0.1", "port": "6379", "password": "goodpassword11233455677898", "database": "0" } }
  • 0 Votes
    3 Posts
    3k Views

    Yes I've tried it.

    Getting an Error. After hours of Google - I have no Idea to fix it:

    nginx: [emerg] "server" directive is not allowed here in /var/www/vhosts/system/ebikeforums.eu/conf/vhost_nginx.conf:1 nginx: configuration file /etc/nginx/nginx.conf test failed