@JaredBusch said in Install Nginx as a Reverse Proxy on Fedora 27:
Before you can request your SSL certificate, you have to have a valid configuration file in place listening on port 80.
Nginx stores the configuration files in /etc/nginx/conf.d/, so let's make our nextcloud.conf.
I am not going to go aver all the pieces here. If you want ot know more about what all these settings mean, go look them up.
Finally, this is a sample base don Nextcloud. Change it to fit your application needs.
The structure may look strange at first, but there is a method to my madness. It is based on how certbot --nginx works.
cat > /etc/nginx/conf.d/nextcloud.conf <<EOF
server {
client_max_body_size 40M;
server_name nc.domain.com;
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_redirect off;
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://10.150.0.17;
proxy_redirect off;
# Socket.IO Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
## ssl_stapling on;
## ssl_stapling_verify on;
## ssl_session_cache shared:SSL:10m;
## add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
listen 80;
}
##server {
## client_max_body_size 40M;
# listen 80;
## server_name nc.domain.com;
## return 301 https://$host$request_uri;
##}
EOF
NOTE: This is on purpose only one # while the others have two, # listen 80;.
Test the config
nginx -t
When I run this step, I get an error.
[root@nginx ~]# nginx -t
nginx: [emerg] invalid number of arguments in "proxy_set_header" directive in /etc/nginx/conf.d/nextcloud.conf:4
nginx: configuration file /etc/nginx/nginx.conf test failed