Home > AI > Frontend > Next.js >

NextAuth.js with Google provider (english92.com)

When trying to create an OAuth2.0 Credential from Google Console, I encountered that has to use https://english92.com:3000 rather than http://english92.com:3000 since the url is recognized as ‘production’.

When running the Next.js on VPS, I found another problem of reverse proxy. The app was running on port 3000.

Nginx was already installed with nginx -v. Find apache version with httpd -v

Use Nginx for reverse proxy

Problem: nginx: [emerg] “load_module” directive is specified too late in /etc/nginx/conf.d/modules/ngx_http_pipelog_module.conf:1

Problem: nginx: [emerg] “server” directive is not allowed here in /etc/nginx/sites-enabled/reverse-proxy:1

Problem: nginx: [emerg] “http” directive is duplicate in /etc/nginx/nginx.conf:19

It seems like you have two server blocks defined: one in the default.conf file and another in the english92.conf file. Both of these server blocks are listening on port 80, which is causing the conflict.

To fix this, you can consolidate the configurations into a single file, such as nginx.conf, and merge the server blocks.

Warning: nginx: [warn] server name “http://english92.com” has suspicious symbols in /etc/nginx/sites-enabled/reverse-proxy:3

Warning: nginx: [warn] conflicting server name “english92.com” on 0.0.0.0:80, ignored

Problem: /etc/nginx/sites-available and /etc/nginx/sites-enabled don’t exist.

https://stackoverflow.com/questions/17413526/nginx-missing-sites-available-directory

My VPS host Nginx and Apache at the same time. Nginx is listening on port 80 and 443 while Apache listens on 81 and 444. Nginx sets a reverse proxy on 80

https://stackoverflow.com/questions/55107024/how-can-i-check-if-current-web-server-is-nginx-or-apache-using-bash-script

if [[ `ps -acx|grep apache|wc -l` > 0 ]]; then
    echo "VM Configured with Apache"
fi
if [[ `ps -acx|grep nginx|wc -l` > 0 ]]; then
    echo "VM Configured with Nginx"
fi



# or

ss -tlnp | grep -E ":80\b"   # nginx
ss -tlnp | grep -E ":443\b"  # nginx
ss -tlnp | grep -E ":81\b"   # apache2
ss -tlnp | grep -E ":444\b"  # apache2

ServerPorts
Nginx80, 443
Apache81, 444

When I set up Nginx to listen on port 3000 using the provided configuration, Next.js doesn’t launch on port 3001, and Nginx fails to redirect traffic from port 3000 to port 80 as intended.

server {
    listen 3000;
    server_name english92.com;

    location / {
        proxy_pass http://english92.com:80;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Leave a Reply