Fix incorrect/inconsistent usage of proxy_set_header in nginx_internal.conf

- Distribute proxy_params to nginx VM, include it as necessary in config
- Resolves #155
This commit is contained in:
Cody Robertson 2023-09-02 19:50:41 -04:00
parent a4af565839
commit 2c9b9aac89
5 changed files with 25 additions and 3 deletions

4
files/proxy_params Normal file
View file

@ -0,0 +1,4 @@
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

View file

@ -157,6 +157,16 @@
- configs
- postgresql
- name: Distribute nginx proxy_params configuration
ansible.builtin.copy:
src: files/proxy_params
dest: "{{ lemmy_base_dir }}/{{ domain }}/proxy_params"
owner: root
group: root
mode: "0644"
tags:
- nginx
- name: Distribute nginx site templates
ansible.builtin.template:
src: "{{ item.src }}"

View file

@ -113,6 +113,14 @@
- set_fact:
lemmy_port: "{{ 32767 |random(start=1024) }}"
- name: Distribute nginx proxy_params configuration
ansible.builtin.copy:
src: files/proxy_params
dest: "{{ lemmy_base_dir }}/{{ domain }}/proxy_params"
owner: root
group: root
mode: "0644"
- name: add template files
template:
src: "{{item.src}}"

View file

@ -16,6 +16,7 @@ services:
- "{{ lemmy_port }}:8536"
volumes:
- ./nginx_internal.conf:/etc/nginx/nginx.conf:ro,Z
- ./proxy_params:/etc/nginx/proxy_params:ro,Z
restart: always
logging: *default-logging
depends_on:

View file

@ -59,9 +59,7 @@ http {
client_max_body_size 20M;
# Send actual client IP upstream
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include proxy_params;
# frontend general requests
location / {
@ -79,6 +77,7 @@ http {
proxy_pass "http://lemmy";
# proxy common stuff
include proxy_params;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";