nginx не работает
This commit is contained in:
@@ -4,3 +4,6 @@ node2 ansible_host=172.17.33.254 nginx_user=root
|
||||
|
||||
[all:vars]
|
||||
ansible_user = cloudadmin
|
||||
node1=172.17.35.153
|
||||
node2=172.17.33.254
|
||||
|
||||
|
||||
+17
-19
@@ -11,14 +11,6 @@
|
||||
name: "*"
|
||||
state: latest
|
||||
|
||||
- name: Install nginx 'Ubuntu'
|
||||
when: ansible_os_family == 'Debian'
|
||||
ansible.builtin.apt:
|
||||
package:
|
||||
- nginx
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Install EPEL repo
|
||||
when: ansible_os_family == 'RedHat'
|
||||
ansible.builtin.yum:
|
||||
@@ -26,23 +18,13 @@
|
||||
- epel-release
|
||||
state: present
|
||||
|
||||
- name: Install nginx & git 'RedHat'
|
||||
- name: Install git 'RedHat'
|
||||
when: ansible_os_family == 'RedHat'
|
||||
ansible.builtin.yum:
|
||||
name:
|
||||
- nginx
|
||||
- git
|
||||
state: present
|
||||
|
||||
- name: Copy config nginx
|
||||
ansible.builtin.template:
|
||||
src: nginx.conf.j2
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload nginx service
|
||||
|
||||
- name: Install NodeJS-18 FRONTEND
|
||||
when: "'node1' in inventory_hostname"
|
||||
become: true
|
||||
@@ -97,4 +79,20 @@
|
||||
command: npm start
|
||||
args:
|
||||
chdir: /src/sample-project/notes-backend/
|
||||
- name: Install nginx 'Ubuntu'
|
||||
when: ansible_os_family == 'Debian'
|
||||
ansible.builtin.apt:
|
||||
package:
|
||||
- nginx
|
||||
state: present
|
||||
update_cache: true
|
||||
- name: Copy config nginx
|
||||
when: "'node1' in inventory_hostname"
|
||||
ansible.builtin.template:
|
||||
src: nginx.conf.j2
|
||||
dest: /etc/nginx/nginx.conf
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
notify: Reload nginx service
|
||||
|
||||
|
||||
@@ -33,5 +33,31 @@ http {
|
||||
proxy_busy_buffers_size 64k;
|
||||
server_names_hash_bucket_size 64;
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
upstream front {
|
||||
server {{ node1 }}:3000;
|
||||
}
|
||||
upstream back {
|
||||
server {{ node2 }}:5000;
|
||||
}
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
location / {
|
||||
proxy_pass http://front;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://back/api;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user