Running Swift Perfect and NGINX - swift

So I have a Swift server-side app running on my Ubuntu box, it's using the Perfect Framework and runs on port 8080.
I want NGINX to forward requests on port 80 to port 8080 (behind the scenes)
My config is
server {
listen 80;
server_name burf.co;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $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;
proxy_read_timeout 90;
} }
I have done similar things with VueJS, Node etc but for what am I missing here?
Is it a Perfect issue?
When I go to 127.0.0.1:8080 the page renders fine

Related

how change my client request ip and forward to another website then return result to client with haproxy and dns

I have a domain name serve with a ha-proxy server. i want when the clients set my domain name server in their computer , when clients want to access ABC.com or def.com their request forward to my ha-proxy server then request sent to ABC.com or def.com (with ha-proxy server IP) and give it back to client.
i don't want all request send over my ha-proxy just when they want to access "ABC.com" or "def.com".
I tried with "ngnix" and do just with one website but i cant do with two or more. any other solution will make me happier.
ok finally i did with nginx but problem exist with https website . here my ngnix configuration :
server {
listen 80;
server_name www.myipaddress.com;
location / {
proxy_pass http://www.myipaddress.com:80;
proxy_set_header Host $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;
}
}
server {
listen 80;
server_name myiplocator.net;
location / {
proxy_pass http://myiplocator.net:80;
proxy_set_header Host $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;
}
}
but when i try with https website .https traffic doesn't go through my reverse proxy here my code :
server {
listen 443;
ssl on;
server_name www.oracle.com oracle.com;
ssl_certificate /etc/nginx/ssl/rpwildcard.crt;
ssl_certificate_key /etc/nginx/ssl/rpwildcard.key;
location / {
proxy_bind 'mynetwork ip interface';
proxy_pass https://www.oracle.com;
proxy_set_header Host $Host;
proxy_set_header X-Real-Ip $remote_addr;

dotnet core 1.x authorize tag change port

Please Help me.
situation:
OS : ubuntu,
WebServer : nginx
DotnetCore Version : 1.0.4
multiple dotnetcore service : 80, 8081
I pubulished two projects with different port 80,8081.
When 8081 service needs authorize, then redirect login page without port.
ex)"xxx.xxxx.xxx/Account/Login" not "xxx.xxxx.xxx:8081/Account/Login"
Is there any way setting redirect with port?
I solved this problem.
There is no way with ip, but It can be solved using domain.
I got free domains and apply them.
freedomain site : http://www.dot.tk/ko/index.html
nginx site setting location : /etc/nginx/sites-available/default
server {
listen 80;
server_name www.xxxx1.tk xxxx1.tk;
location / {
proxy_pass http://localhost:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
server {
listen 80;
server_name www.xxxx2.tk xxxx2.tk;
location / {
proxy_pass http://localhost:5002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}

Mixed HTTP / HTTPS content with Gitlab behind a reverse proxy

I'm running sameersbn/docker behind a nginx reverse proxy, but I get a mixed content warning on the avatar image.
No matter what I try, it is either the mixed content warning or a too many redirects error page.
I forward my http traffic automatically in nginx with this config:
server
{
listen 80;
server_name myserver.com;
return 301 https://myserver.com$request_uri;
}
server
{
listen 443 ssl;
server_name myserver.com;
ssl on;
ssl_certificate myserver.cert.combined;
ssl_certificate_key myserver.key;
include nginx_php.conf;
location / {
proxy_set_header X-Forwarded-Proto: https;
proxy_set_header X-Forwarded-Ssl: on;
proxy_pass http://127.0.0.1:10080;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
include /etc/nginx/webapps.ssl.conf;
}
As soon as I run my gitlab container with the following options, I get the too many redirects
- GITLAB_HTTPS=true
- SSL_SELF_SIGNED=false
- GITLAB_HOST=myserver.com
- GITLAB_PORT=443
- GITLAB_SSH_PORT=22
What am I doing wrong here?
And why does Gitlab try to load the avatar over http?

Nginx - redirect www to https : ERR_SSL_PROTOCOL_ERROR

I tried to copy the configuration file of my other website but it doesn't work for it, maybe because I have a proxy on it ? I really don't know what's the problem. https://mywebsite.lol is ok (SSL by cloudflare)
server {
server_name www.irc.mywebsite.lol;
rewrite ^(.*) https://irc.mywebsite.lol$1 permanent;
}
server {
# Port
listen 80;
# Hostname
server_name irc.mywebsite.lol;
# Logs (acces et erreurs)
access_log /var/log/nginx/irc.mywebsite.lol.access.log;
error_log /var/log/nginx/irc.mywebsite.lol.error.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_pass http://localhost:7778/;
proxy_redirect default;
# Websocket support (from version 1.4)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
pagespeed off;
}
}
Use HTTPS port, not HTTP. It should be
listen 443;
instead of
listen 80;

How to deploy puma with nginx

How to deploy puma with nginx or apache, is this possible or it's not necessary to use a web server like nginx or apache. What is the best way to deploy an app with puma?
The key is in the nginx conf for the site.
server {
listen 80;
server_name mysite.com;
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_redirect off;
proxy_pass http://localhost:4000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
As you can see proxy_pass http://localhost:4000; line tells nginx to listen to localhost at port 4000 you can change that to your needs.
This is a small change to work with ssl letsencrypt, of course you should configure ssl with letsencrypt.
server {
listen 80;
server_name example.com;
location / {
return 301 https://example.com$request_uri;
}
}
server {
listen 443 ssl http2;
server_name example.com;
#listen [::]:443 ssl http2 ipv6only=on;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
include /etc/nginx/snippets/ssl.conf;
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_redirect off;
proxy_pass http://localhost:4000;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
As Puma is not designed to be accessed by users directly, we will use Nginx as a reverse proxy that will buffer requests and responses between users and your Rails application. Puma uses threads, in addition to worker processes, to make more use of available CPU. Nginx and communication between puma is made through socket:
Source Image : http://codeonhill.com
If you need explanation of how to deploy applications with Puma and Nginx checks this