Making a subdomain with NGINX?

Technical Support

Suggested Topics


  • nginx reverse proxy SSL

    Technical Support
    0 Votes
    4 Posts
    459 Views

    @oplik0 yeah we are having a loadbalancer before nginx!

    using nodebb without SSL works perfectly using load balancer -> nginx -> nodebb

    I would need to do some more testing but I saw that when using SSL , it redirect to www.domain.tld instead of domain.tld!

    I just modify the nginx config for this vhost to send www. to non-www. and I will re-active the SSL!

    The other thing is, I tried to add

    "socket.io": { "origins": "https://community.nodebb.org:* https://nodebb.org:*" }

    to the config.json and I got an error when starting nodebb

  • 0 Votes
    9 Posts
    512 Views

    ☠ ☠ ☠ Check the credit card!!! ☠ ☠ ☠

    🤷

  • 0 Votes
    7 Posts
    1k Views

    So, with this configuration, it's ok !

    <VirtualHost *:80> ServerName mydomain.com ServerAdmin [email protected] DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, e.g. #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^[^\/]*\/(.*) https://mydomain.com/$1 [R=301,L] </IfModule> RewriteCond %{SERVER_NAME} =mydomain.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost> <VirtualHost *:4567> ServerName subdomain.mydomain.com # Basic security headers Header always set X-Content-Type-Options "nosniff" Header always set X-Xss-Protection "1; mode=block" # NodeBB header RequestHeader set X-Forwarded-Proto "https" # Static file cache <FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css)$"> <IfModule mod_expires.c> ExpiresActive on ExpiresDefault "access plus 14 days" Header set Cache-Control "public" </IfModule> </FilesMatch> ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> # Custom Error Document when NodeBB is offline ProxyPass /error-documents ! ErrorDocument 503 /error-documents/503.html Alias /error-documents path/to/nodebb/public # Websocket passthrough RewriteEngine On RewriteCond %{REQUEST_URI} ^/socket.io [NC] RewriteCond %{QUERY_STRING} transport=websocket [NC] RewriteRule /(.*) ws://localhost:4567/$1 [P,L] ProxyPass / http://localhost:4567/ ProxyPassReverse / http://localhost:4567/ # Log stuff ErrorLog ${APACHE_LOG_DIR}/nodebb-error.log CustomLog ${APACHE_LOG_DIR}/nodebb-access.log combined RewriteCond %{SERVER_NAME} =subdomain.mydomain.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>

    The problem is that I had not put 2 different ServerName in the config, so all traffic was redirected and rewritten in HTTPS on the same ServerName : subdomain.mydomain.com

  • 0 Votes
    2 Posts
    897 Views

    Please consult the nginx documentation: https://docs.nodebb.org/configuring/proxies/nginx/

  • 0 Votes
    3 Posts
    1k Views

    thank you so much. i'm sorry that i haven't found this by searching, but I was in a hurry because we worked on launching a closed beta version of our board so things got a little bit hectic in the last days